Re: int4 -> unix timestamp -> sql timestamp; abstime? - Mailing list pgsql-general

From David Fetter
Subject Re: int4 -> unix timestamp -> sql timestamp; abstime?
Date
Msg-id 20050112004024.GA3847@fetter.org
Whole thread Raw
In response to Re: int4 -> unix timestamp -> sql timestamp; abstime?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: int4 -> unix timestamp -> sql timestamp; abstime?
List pgsql-general
On Tue, Jan 11, 2005 at 06:35:18PM -0500, Tom Lane wrote:
> Roman Neuhauser <neuhauser@chello.cz> writes:
> > what is the opposite of cast(extract('epoch' from now()) as int)?
> > The only thing I found that works is
> > cast(cast(... as abstime) as timestamp)
> > and the documentation says abstime shouldn't be used, and may
> > disappear. What should I use instead?
>
> The recommended locution is
>
> SELECT TIMESTAMP WITH TIME ZONE 'epoch' + <x> * INTERVAL '1 second';

I think this should read:

SELECT TIMESTAMP WITH TIME ZONE 'epoch' AT TIME ZONE 'UTC' + <x> * INTERVAL '1 second';
/*                                      ^^^^^^^^^^^^^^^^^^ */

to conform with the *n*x standard.

Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: int4 -> unix timestamp -> sql timestamp; abstime?
Next
From: Tom Lane
Date:
Subject: Re: int4 -> unix timestamp -> sql timestamp; abstime?