Re: epoch to show millseconds

From: mars g miro <mars(at)cannoncreek(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-sql(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: epoch to show millseconds
Date: 2001-07-18 01:22:03
Message-ID: 01071809220300.03387@hellraiser.cannoncreek.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday 18 July 2001 09:32, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > > Mars G Miro <mars(at)cannoncreek(dot)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.
>

Well, I managed to have a workaround for it by:
punkdb=# select date_part('epoch', current_timestamp) ||
trim(to_char(date_part('millisecond', timeofday()::timestamp),'999'));

?column?
--------------
995418886281
(1 row)

> 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.
>

This is on 7.0.3

> regards, tom lane

My sole purpose is to generate a primary key, w/c I believe is sufficient and
unique enough to avoid double records (or errors that an existing record of
the same epoch exist, if it's only up to the second).

Thanks, for the response though, I really appreciate it ;-)

cheers
mars
--
"I gained nothing at all from Supreme Enlightenment, and for that very
reason it is called Supreme Enlightenment."
-- Gotama Buddha

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2001-07-18 02:28:47 Re: undeleteable records
Previous Message Martijn van Oosterhout 2001-07-18 00:58:25 Re: Partial Indices vs. mixing columns and functions