Re: BUG #5031: DATE_TRUNC returns the wrong value when specifying MONTH

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Mark Douglas" <mark(at)steelhousemedia(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5031: DATE_TRUNC returns the wrong value when specifying MONTH
Date: 2009-09-03 05:01:44
Message-ID: 8052.1251954104@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Mark Douglas" <mark(at)steelhousemedia(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Mark Douglas 2009-09-03 05:06:03 Re: BUG #5031: DATE_TRUNC returns the wrong value when specifying MONTH
Previous Message Keith Cascio 2009-09-03 04:48:02 Re: BUG #5032: unexpected syntax error for plpgsql function returns table