rounding timestamps

Поиск
Список
Период
Сортировка
От Claudio Lapidus
Тема rounding timestamps
Дата
Msg-id BAY7-DAV10Yxt0Gfwb300002210@hotmail.com
обсуждение исходный текст
Ответы Re: rounding timestamps  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Re: rounding timestamps  (Joe Conway <mail@joeconway.com>)
Список pgsql-general
Hello

(Sorry about reposting, but I'm still not arriving to any good solution for
this one)

I need to output a timestamp attribute formatted to fixed-width, no spaces
nor separators, something like

test=> select to_char(timestamp '2003-10-24 15:30:59.999',
'YYYYMMDDHH24MISS');
    to_char
----------------
 20031024153059
(1 row)

But my problem is that to_char truncates the fractional seconds, and I need
to round the value to the nearest integer second. In the above, I would need
the output rounded to 15:31:00, which is just a millisecond away, for
example. But I couldn't find a function to round a timestamp. Are there any
workaround?

thanks
cl.

В списке pgsql-general по дате отправления:

Предыдущее
От: "Craig O'Shannessy"
Дата:
Сообщение: Re: Export CSV from psql
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: rounding timestamps