Re: 'epoch'::timestamp and Daylight Savings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Hosen, John" <John(dot)Hosen(at)capita(dot)co(dot)uk>
Cc: "'Thomas Lockhart'" <lockhart(at)fourpalms(dot)org>, "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: 'epoch'::timestamp and Daylight Savings
Date: 2002-10-23 18:46:33
Message-ID: 3144.1035398793@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Hosen, John" <John(dot)Hosen(at)capita(dot)co(dot)uk> writes:

> e_app_print_date | timestamp with time zone | default
> "timestamp"('epoch'::text)

Yeah, there's your problem. You are casting 'epoch' to type timestamp
without time zone, and thence to timestamp with time zone. The first
step gives "midnight" and the second assumes that that means "midnight
local time".

For example, in US EST zone I get:

regression=# select "timestamp"('epoch'::text);
timestamp
---------------------
1970-01-01 00:00:00
(1 row)

regression=# select ("timestamp"('epoch'::text))::timestamptz;
timestamp
------------------------
1970-01-01 00:00:00-05
(1 row)

whereas what is wanted is

regression=# select "timestamptz"('epoch'::text);
timestamptz
------------------------
1969-12-31 19:00:00-05
(1 row)

So you can fix the problem just by setting the default to be
'epoch'::timestamptz.

The problem is probably related to the renaming we've been carrying out
to get closer to the SQL spec: "timestamp" now means timestamp without
time zone, which is not what it meant in older Postgres releases.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeugswetter Andreas SB SD 2002-10-23 18:58:13 Re: PREPARE / EXECUTE
Previous Message Hans-Jürgen Schönig 2002-10-23 18:09:37 Re: PREPARE / EXECUTE