Search Postgresql Archives

Re: timestamp <-> ctime conversion question...

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

 



Alex Mayrhofer <axelm@xxxxxxxx> writes:
> i'm trying to convert time stamps to "seconds since epoch" and back.

> test=# SELECT (TIMESTAMP WITH TIME ZONE 'epoch'
>                  + 0 * INTERVAL '1 second') AT TIME ZONE 'UTC';

You're overthinking the problem.  It should be just

	SELECT (TIMESTAMP WITH TIME ZONE 'epoch' + n * INTERVAL '1 second')

There is a built-in function to_timestamp() equivalent to this in 8.1,
though it doesn't seem to have made it into the documentation :-(

			regards, tom lane


[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