The following bug has been logged online:
Bug reference: 6219
Logged by: Eric Vollnogel
Email address: edvollnogel@dstsystems.com
PostgreSQL version: 9.0.4 64bit
Operating system: Windows 7 SP 1 64bit
Description: date_part() function producting incorrect year
Details:
The date_part('isoyear', some_column) function is not always returning the
correct result. See below:
Example 1: (date_part returns incorrect year)
SQL:
SELECT date_part('isoyear', observation_start), observation_start FROM
service_point_observations
WHERE observation_start >= '2011-01-01'
AND observation_start < '2011-01-02'
LIMIT 5;
Output:
2010;"2011-01-01 00:00:00-06"
2010;"2011-01-01 00:00:00-06"
2010;"2011-01-01 00:00:00-06"
2010;"2011-01-01 00:00:00-06"
2010;"2011-01-01 00:00:00-06"
Example 2: (date_part returns incorrect year)
SQL:
SELECT date_part('isoyear', observation_start), observation_start FROM
service_point_observations
WHERE observation_start >= '2011-01-02'
AND observation_start < '2011-01-03'
LIMIT 5;
Output:
2010;"2011-01-02 00:00:00-06"
2010;"2011-01-02 00:00:00-06"
2010;"2011-01-02 00:00:00-06"
2010;"2011-01-02 00:00:00-06"
2010;"2011-01-02 00:00:00-06"
Example 2: (date_part returns CORRECT year)
SQL:
SELECT date_part('isoyear', observation_start), observation_start FROM
service_point_observations
WHERE observation_start >= '2011-01-03'
AND observation_start < '2011-01-04'
LIMIT 5;
Output:
2011;"2011-01-03 00:00:00-06"
2011;"2011-01-03 00:00:00-06"
2011;"2011-01-03 00:00:00-06"
2011;"2011-01-03 00:00:00-06"
2011;"2011-01-03 00:00:00-06"
Thank you for your assistance,
ERIC VOLLNOGEL