timestamp/date bug

From: juan(at)netsoc(dot)tcd(dot)ie (Juan Flynn)
To: pgsql-bugs(at)postgresql(dot)org
Subject: timestamp/date bug
Date: 2001-02-04 18:31:54
Message-ID: 20010204183154.A2598@netsoc.tcd.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I've come across an odd bug in Postgres 7 (7.0.3 I think) that's probably
best explained with an example:

SELECT to_char(timestamp '23-Mar-2000' + 1, 'Mon DD');
to_char
---------
Mar 24
(1 row)

Which is correct.

SELECT to_char(timestamp '23-Mar-2000' + 2, 'Mon DD');
to_char
---------
Mar 25
(1 row)

Also fine, but...

SELECT to_char(timestamp '23-Mar-2000' + 3, 'Mon DD');
to_char
---------
Mar 25
(1 row)

Which is wrong, however:

SELECT to_char(timestamp '23-Mar-2000' + 4, 'Mon DD');
to_char
---------
Mar 27
(1 row)

is correct.

This odd date bug seems to skip over March 26 2000, and it occurs also
on March 25 2001 and March 30 2002.

It caught me by surprise as I've been using Postgres for a while now and it's been
working really well, and the other day I got a phone call saying there was
no March 25. A current workaround is for me to redo the whole project with
dates and times instead of timestamps but that's a bit of a big job as they
are using the database everyday now.

Regards,
Juan

_________________________________________________________________________
Juan Flynn juan(at)netsoc(dot)tcd(dot)ie
P.R.O., Dublin University Internet Society www.netsoc.tcd.ie

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2001-02-04 20:15:34 Re: syslog logging setup broken?
Previous Message Peter Eisentraut 2001-02-04 15:10:14 Re: syslog logging setup broken?