timestamp/date bug - Mailing list pgsql-bugs

From juan@netsoc.tcd.ie (Juan Flynn)
Subject timestamp/date bug
Date
Msg-id 20010204183154.A2598@netsoc.tcd.ie
Whole thread Raw
Responses Re: timestamp/date bug  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: timestamp/date bug  (Karel Zak <zakkr@zf.jcu.cz>)
List 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@netsoc.tcd.ie
P.R.O., Dublin University Internet Society                 www.netsoc.tcd.ie

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: psql & "unexpected EOF on client connection"
Next
From: Alex Krohn
Date:
Subject: Re: select fails on indexed varchars.