Re: BUG #1768: to_char result of an interval differs between 7.x and 8.x - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #1768: to_char result of an interval differs between 7.x and 8.x
Date
Msg-id 20050714205707.GJ19778@alvh.no-ip.org
Whole thread Raw
In response to BUG #1768: to_char result of an interval differs between 7.x and 8.x  ("" <michael.oeztuerk@haufe.de>)
Responses Re: BUG #1768: to_char result of an interval differs between
List pgsql-bugs
On Thu, Jul 14, 2005 at 08:01:11AM +0100, michael.oeztuerk@haufe.de wrote:

> When using the following SQL statement the result of a 8.0.3 seems to be
> wrong.
>
> Statement: "select to_char(interval '15h 2m 12s', 'YYYYMMDD HH24:MI:SS')"
> Result of a 8.0.3: "00010000 15:02:12"
> The error in the Result is that it´s "one year behind".

Yeah, it's strange:

alvherre=# select to_char(interval '15h 2m 12s', 'YYYY-MM-DD HH24:MI:SS');
       to_char
---------------------
 0001-00-00 15:02:12
(1 fila)

alvherre=# select to_char(interval '15h 2m 12s', 'CCYY-MM-DD HH24:MI:SS');
       to_char
---------------------
 0101-00-00 15:02:12
(1 fila)

alvherre=# select version();
                                           version
----------------------------------------------------------------------------------------------
 PostgreSQL 8.1devel on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.6 (Debian 1:3.3.6-7)
(1 fila)


On 7.4 however the year stays at 0, but centuries seem wrong too:

alvherre=# select to_char(interval '15h 2m 12s', 'CCYY-MM-DD HH24:MI:SS');
       to_char
---------------------
 0100-00-00 15:02:12
(1 row)

alvherre=# select version();
                                          version
--------------------------------------------------------------------------------------------
 PostgreSQL 7.4.6 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.5 (Debian 1:3.3.5-12)
(1 row)


--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"The problem with the future is that it keeps turning into the present"
(Hobbes)

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #1769: pg_dumpall fails to run
Next
From: David Fetter
Date:
Subject: Composite Type dependency bug