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

From: "Mark Douglas" <mark(at)steelhousemedia(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5031: DATE_TRUNC returns the wrong value when specifying MONTH
Date: 2009-09-02 23:07:16
Message-ID: 200909022307.n82N7G6c075627@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5031
Logged by: Mark Douglas
Email address: mark(at)steelhousemedia(dot)com
PostgreSQL version: 8.4.0
Operating system: Ubunto Linux
Description: DATE_TRUNC returns the wrong value when specifying MONTH
Details:

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.

Casting CURRENT_DATE to a TIMESTAMP causes it to return the correct value
but that shouldn't be required. Cast example:

SELECT DATE_TRUNC('MONTH', CAST(CURRENT_DATE AS TIMESTAMP));

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Haas 2009-09-03 01:21:55 Re: BUG #5028: CASE returns ELSE value always when type is"char"
Previous Message Kevin Grittner 2009-09-02 21:53:35 Re: BUG #5028: CASE returns ELSE value always when type is"char"