Re: April 1 - Mailing list pgsql-general

From Tom Lane
Subject Re: April 1
Date
Msg-id 24284.1015208451@sss.pgh.pa.us
Whole thread Raw
In response to April 1  ("Andrew Bartley" <abartley@evolvosystems.com>)
List pgsql-general
"Andrew Bartley" <abartley@evolvosystems.com> writes:
> I'm having trouble calculating a date of April 1 2002.

What is the daylight savings transition day in your timezone?
(I'm betting March 31.)

> It seems as though the "+ interval('1 day'))" only adds 23 hours rather tha=
> n 24.

No, interval('1 day') is exactly 24 hours.  But March 31 is longer than
24 hours.  You're computing March 31 23:00 hours, and then truncating
that back to March 31.

If you want to calculate at the date level I'd suggest calculating with
dates, not timestamps.

regression=# select date('2002-03-31') + 1;
  ?column?
------------
 2002-04-01
(1 row)

            regards, tom lane

pgsql-general by date:

Previous
From: Samik Raychauhduri
Date:
Subject: Conditional Statement
Next
From: Medi Montaseri
Date:
Subject: Re: Conditional Statement