Re: timestamp <-> ctime conversion question... - Mailing list pgsql-general

From Tom Lane
Subject Re: timestamp <-> ctime conversion question...
Date
Msg-id 8305.1134496150@sss.pgh.pa.us
Whole thread Raw
In response to timestamp <-> ctime conversion question...  (Alex Mayrhofer <axelm@nona.net>)
Responses Re: timestamp <-> ctime conversion question...
Setting expire date on insert/modify
List pgsql-general
Alex Mayrhofer <axelm@nona.net> 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

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Bug#342369: PostgreSQL 8.1.0 RHEL / Debian incompatible
Next
From: Tom Lane
Date:
Subject: Re: Memory Leakage Problem