BUG #3586: Time zone problem in SQL query

From: "George Wright" <george(dot)wright(at)infimatic(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3586: Time zone problem in SQL query
Date: 2007-08-29 19:11:03
Message-ID: 200708291911.l7TJB3ox084678@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 3586
Logged by: George Wright
Email address: george(dot)wright(at)infimatic(dot)com
PostgreSQL version: 8.1.5
Operating system: SUSE Linux 10.2
Description: Time zone problem in SQL query
Details:

I checked release notes up to 8.2.4 but only found references to new USA DST
rules and time zone database changes for Canada and Australia.

When supplying a timezone for dates, PostGreSQL appears to return incorrect
rows for a query. Table is called tz. Sample data is shown at the top.
Notice the number of rows returned when -06 is supplied, differs from when
-03 through -05 are supplied. I'm in EDT when running the query. Data is in
EST. It appears the first row is returned in error when supplying -03
throught -05, but I'm not sure.

badger=> select logid, starttime from tz;
logid | starttime
-------+------------------------
1 | 2007-01-22 23:00:00-06
2 | 2007-01-22 23:30:00-06
3 | 2007-01-23 00:00:00-06
4 | 2007-01-23 00:30:00-06
5 | 2007-01-23 01:00:00-06
(5 rows)

badger=> select logid, starttime from tz where starttime BETWEEN '2007-01-22
02:30:00-03' and '2007-01-23 03:00:00-03';
logid | starttime
-------+------------------------
1 | 2007-01-22 23:00:00-06 <- is this right?
2 | 2007-01-22 23:30:00-06
3 | 2007-01-23 00:00:00-06
(3 rows)

badger=> select logid, starttime from tz where starttime BETWEEN '2007-01-22
01:30:00-04' and '2007-01-23 02:00:00-04';
logid | starttime
-------+------------------------
1 | 2007-01-22 23:00:00-06 <- is this right?
2 | 2007-01-22 23:30:00-06
3 | 2007-01-23 00:00:00-06
(3 rows)

badger=> select logid, starttime from tz where starttime BETWEEN '2007-01-22
00:30:00-05' and '2007-01-23 01:00:00-05';
logid | starttime
-------+------------------------
1 | 2007-01-22 23:00:00-06 <- is this right?
2 | 2007-01-22 23:30:00-06
3 | 2007-01-23 00:00:00-06
(3 rows)

badger=> select logid, starttime from tz where starttime BETWEEN '2007-01-22
23:30:00-06' and '2007-01-23 00:00:00-06';
logid | starttime
-------+------------------------
2 | 2007-01-22 23:30:00-06
3 | 2007-01-23 00:00:00-06
(2 rows)

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message cyrus 2007-08-29 21:02:42 BUG #3587: EXECUTE and trigger problem
Previous Message Decibel! 2007-08-28 23:46:55 Re: [SPAM] Re: BUG #3484: Missing pg_clog file / corrupt index