BUG #6219: date_part() function producting incorrect year - Mailing list pgsql-bugs

From Eric Vollnogel
Subject BUG #6219: date_part() function producting incorrect year
Date
Msg-id 201109212117.p8LLHVwW007284@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #6219: date_part() function producting incorrect year
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Broken selectivity with special inet operators
Next
From: Guillaume Smet
Date:
Subject: Re: BUG #6219: date_part() function producting incorrect year