Re: PG producing odd results on epoch timestamp to string conversion

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Preston Landers <planders(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PG producing odd results on epoch timestamp to string conversion
Date: 2011-09-09 22:13:59
Message-ID: 17108.1315606439@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Preston Landers <planders(at)gmail(dot)com> writes:
> SELECT TO_CHAR( TIMESTAMP WITH TIME ZONE 'epoch' + 1315503340 *
> INTERVAL '1 second', 'MM-DD-YYYY HH:MM:SS TZ');
> 09-08-2011 12:09:40 CDT

> As you can see, Python, SQL Server, and Oracle all agree that the
> timestamp 1315503340 means 12:35:40 CDT on that date.

So does Postgres.

regression=# set timezone = 'CST6CDT';
SET
regression=# select TIMESTAMP WITH TIME ZONE 'epoch' + 1315503340 *
INTERVAL '1 second';
?column?
------------------------
2011-09-08 12:35:40-05
(1 row)

> Yet PostgreSQL
> shows a value that is exactly 26 minutes behind the others (12:09:40).

You've fat-fingered the to_char usage --- MM is month, not minutes
(I think you want MI for that).

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Preston Landers 2011-09-10 00:14:24 Re: PG producing odd results on epoch timestamp to string conversion
Previous Message Preston Landers 2011-09-09 21:01:21 PG producing odd results on epoch timestamp to string conversion