Search Postgresql Archives

Re: int4 -> unix timestamp -> sql timestamp; abstime?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Roman Neuhauser <neuhauser@xxxxxxxxx> 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';

Of course you can wrap this up in a function if you prefer (not sure why
we haven't done so already).

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@xxxxxxxxxxxxxx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux