Re: BUG #5031: DATE_TRUNC returns the wrong value when specifying MONTH - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5031: DATE_TRUNC returns the wrong value when specifying MONTH
Date
Msg-id 8052.1251954104@sss.pgh.pa.us
Whole thread Raw
In response to BUG #5031: DATE_TRUNC returns the wrong value when specifying MONTH  ("Mark Douglas" <mark@steelhousemedia.com>)
Responses Re: BUG #5031: DATE_TRUNC returns the wrong value when specifying MONTH  (Mark Douglas <mark@steelhousemedia.com>)
List pgsql-bugs
"Mark Douglas" <mark@steelhousemedia.com> writes:
> The following use of DATE_TRUNC returns the wrong value. I called the
> function on 2009-09-02. It should return '2009-09-01 00:00:00' for the
> following usage:

> SELECT DATE_TRUNC('MONTH', CURRENT_DATE);

> It instead returns '2009-08-31 17:00:00.

Really?  What timezone setting are you using?  I get

postgres=# SELECT DATE_TRUNC('MONTH', CURRENT_DATE);
       date_trunc
------------------------
 2009-09-01 00:00:00-04
(1 row)

with timezone set to 'America/New_York' or equivalent.
This test might also be instructive:

postgres=# select CURRENT_DATE::timestamptz;
      timestamptz
------------------------
 2009-09-03 00:00:00-04
(1 row)


            regards, tom lane

pgsql-bugs by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: BUG #5032: unexpected syntax error for plpgsql function returns table
Next
From: Tom Lane
Date:
Subject: Re: BUG #5031: DATE_TRUNC returns the wrong value when specifying MONTH