Re: Problem with interval - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Problem with interval
Date
Msg-id 466.1097099591@sss.pgh.pa.us
Whole thread Raw
In response to Problem with interval  (Bruno Prévost <bp@interaction.ws>)
List pgsql-bugs
Bruno Prévost <bp@interaction.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


pgsql-bugs by date:

Previous
From: "Sean Utt"
Date:
Subject: Re: Problem with interval
Next
From: "PostgreSQL Bugs List"
Date:
Subject: BUG #1282: LIKE clause double-unescapes characters