Re: Inconsistent time interval formatting

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Allen Chen <rocklob(at)gmail(dot)com>
Cc: Gary Chambers <gwchamb(at)gwcmail(dot)com>, Ben Chobot <bench(at)silentmedia(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Inconsistent time interval formatting
Date: 2011-01-14 00:23:30
Message-ID: 20736.1294964610@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Allen Chen <rocklob(at)gmail(dot)com> writes:
>> That won't really help. The fundamental point here is that '1 day' is
>> not the same concept as '24 hours', because of DST changes; and the
>> interval type treats them as different.

> I don't understand how DST changes matter for a time interval or how that
> could even be factored into calculations. Could you elaborate on that?

The main case where it matters is timestamp plus or minus interval.
As an example, 2011-03-13 is a DST transition day where I live. So:

regression=# select '2011-03-13 01:00'::timestamptz;
timestamptz
------------------------
2011-03-13 01:00:00-05
(1 row)

regression=# select '2011-03-13 01:00'::timestamptz + '1 day'::interval;
?column?
------------------------
2011-03-14 01:00:00-04
(1 row)

regression=# select '2011-03-13 01:00'::timestamptz + '24 hours'::interval;
?column?
------------------------
2011-03-14 02:00:00-04
(1 row)

"Add 1 day" means "produce the same local time on the next day", whereas
"add 24 hours" means exactly that.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nimesh Satam 2011-01-14 04:01:25 Stuck "idle in transaction (aborted)"
Previous Message Dan Birken 2011-01-13 23:55:11 Re: Question about concurrent synchronous and asynchronous commits