Обсуждение: epoch to show millseconds

Поиск
Список
Период
Сортировка

epoch to show millseconds

От
Mars G Miro
Дата:
Hi All
I've searched the archives, but it seems that there's no mention of this.
Basically, what I want to do is to show the milliseconds value.
When I do a:sample=# select date_part('epoch', current_timestamp); date_part----------- 994832815
how do I make it accurate up to milliseconds value? the above is only up to
seconds.This is on Postgresql-7.0.3, btw.Thanks!



cheers
mars
PS. pls CC me as I'm not subscribed


Re: epoch to show millseconds

От
Tom Lane
Дата:
Mars G Miro <mars@cannoncreek.com> writes:
>     how do I make it accurate up to milliseconds value?

You don't.  current_timestamp depends on the time() system call,
which only returns a number accurate to one second.

There is a higher-precision current time function in 7.1, but I
forget the details ... see the docs.  IIRC it existed but was
buggy in 7.0, so you'll need to update.

            regards, tom lane

Re: epoch to show millseconds

От
Grant
Дата:
> Hi All
>
>     I've searched the archives, but it seems that there's no mention of this.
> Basically, what I want to do is to show the milliseconds value.

FAQ: How can I select the time with milliseconds?

binary_data=# select date_part('millisecond', timeofday()::timestamp);
date_part
------------------
534.253999999997

A person asked this question a while back in #Postgresql on IRC EFNet.