Thread: BUG #12367: Wrong result on to_char() when inputing dates

BUG #12367: Wrong result on to_char() when inputing dates

From
Israelins85@yahoo.com.br
Date:
The following bug has been logged on the website:

Bug reference:      12367
Logged by:          Israel
Email address:      Israelins85@yahoo.com.br
PostgreSQL version: 9.3.5
Operating system:   MacOs/Windows/Linux
Description:

this select shows the diference:

SELECT
to_char(('2014-12-28 22:01:39.151-03' AT TIME ZONE 'UTC'),
'IYYY-MM-DD"T"HH24:MI:SS.MS"Z"'),
to_char(('2014-12-28 22:01:39.151-03' AT TIME ZONE 'UTC'),
'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')

Re: BUG #12367: Wrong result on to_char() when inputing dates

From
Tom Lane
Date:
Israelins85@yahoo.com.br writes:
> this select shows the diference:

> SELECT
> to_char(('2014-12-28 22:01:39.151-03' AT TIME ZONE 'UTC'),
> 'IYYY-MM-DD"T"HH24:MI:SS.MS"Z"'),
> to_char(('2014-12-28 22:01:39.151-03' AT TIME ZONE 'UTC'),
> 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')

The results look correct to me: today is the first day of ISO year
2015.  See
http://en.wikipedia.org/wiki/ISO_week_date

The construction IYYY-MM-DD basically never makes any sense.  You
should use IYYY with IDDD and/or IW.

            regards, tom lane