Re: Problem with interval

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Prévost <bp(at)interaction(dot)ws>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Problem with interval
Date: 2004-10-06 21:53:11
Message-ID: 466.1097099591@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?iso-8859-1?Q?Bruno_Pr=E9vost?= <bp(at)interaction(dot)ws> writes:
> I'm using postgres version 7.4.5 and had a problem with interval

> Here is my query :
> select '2004/10/31'::timestamptz + '1 day'::interval;

> Here is the answer :
> 10/31/2004 11:00:00 PM

If you are in a US time zone then that's the expected answer, because
2004/10/31 is a DST transition day. '1 day' is currently always taken
to mean '24 hours', and 2004/10/31 is in fact 25 hours long...

Personally I would like to see the interval type redone so that days are
separate from smaller units and this case behaves more intuitively.
But that's been on the wish list for years and it's not gotten to the
top of anyone's to-do list.

In the meantime, you might ask yourself if you really want to use
type timestamptz at all, as opposed to date. ('2004/10/31'::date + 1
would give the answer you want.) Or consider using timestamp without
time zone.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sean Utt 2004-10-06 21:54:40 Re: Problem with interval
Previous Message Michael Fuhr 2004-10-06 21:47:55 Re: Problem with interval