Re: to_char miscalculation on April Fool's Day - the start of daylight savings - Mailing list pgsql-bugs

From Thomas Lockhart
Subject Re: to_char miscalculation on April Fool's Day - the start of daylight savings
Date
Msg-id 3ACDCAAD.74C3210B@alumni.caltech.edu
Whole thread Raw
In response to to_char miscalculation on April Fool's Day - the start of daylight savings  (Chris Straka <cstraka@incontactnow.com>)
Responses Re: Re: to_char miscalculation on April Fool's Day - the start of daylight savings
List pgsql-bugs
> It's April 3 and I'm developing an update routine to maintain expired
> records, some of which expired on April 1.  When these records didn't get
> updated, I investigated and identified the alleged bug (which is
> potentially devastating based on date intensive calculations in financial
> applications).

A known problem which is fixed in the upcoming release. Workaround
follows...

> The quickest demonstration is as follows:
> select to_char(now(), 'YYYY-MM-DD');

Have you tried to use "date 'today'" rather than "now()"? As in

  select to_char(date 'today' - 1, 'YYYY-MM-DD');

which uses the DATE type rather than ABSTIME/TIMESTAMP returned from
now(). That should eliminate the problem, since the DATE type does not
try to carry along time zone information. Seems to work for me on 7.0.3.

                      - Thomas

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Unexpected query results
Next
From: Tom Lane
Date:
Subject: Re: Re: to_char miscalculation on April Fool's Day - the start of daylight savings