| От | Tom Lane |
|---|---|
| Тема | Re: EPCOH: extract returns millisecs too? |
| Дата | |
| Msg-id | 19966.1029387605@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | EPCOH: extract returns millisecs too? (Jean-Christian Imbeault <jc@mega-bucks.co.jp>) |
| Список | pgsql-general |
Jean-Christian Imbeault <jc@mega-bucks.co.jp> writes:
> [ the docs state ]
> SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40');
> Result: 982352320
Sure, that is an exact-second timestamp; it's not going to have any
fractional-second component.
> But if I seem to get milliseconds too in my queries:
> $ psql sessions -c "SELECT EXTRACT(EPOCH FROM current_timestamp) as now"
> now
> ------------------
> 1029298563.74248
> (1 row)
> Are the Docs out of date? How can I get EXTRACT to only return seconds?
We return fractional seconds in current_timestamp since 7.2. You can
use current_timestamp(0) to round the result to seconds, or just apply
round() to EXTRACT's result.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера