BUG #6126: CC parameter in to_char() behaves incorrectly - Mailing list pgsql-bugs

From Artem Andreev
Subject BUG #6126: CC parameter in to_char() behaves incorrectly
Date
Msg-id 201107210840.p6L8eBeA041492@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #6126: CC parameter in to_char() behaves incorrectly
List pgsql-bugs
The following bug has been logged online:

Bug reference:      6126
Logged by:          Artem Andreev
Email address:      artem@oktetlabs.ru
PostgreSQL version: 9.0.4
Operating system:   Debian 6.0
Description:        CC parameter in to_char() behaves incorrectly
Details:

CC parameter in to_char() behaves incorrectly with BC dates:

1st century BC:

select to_char('0002-01-01 00:00:00 BC' :: timestamp, 'CC');
====>
 to_char
---------
 01

2nd century BC:

 select to_char('0101-01-01 00:00:00 BC' :: timestamp, 'CC');
=====>
 to_char
---------
 00

3rd century BC:
iliran=> select to_char('0301-01-01 00:00:00 BC' :: timestamp, 'CC');
 to_char
---------
 -2

In all these cases EXTRACT(CENTURY FROM ...) yields the expected result

pgsql-bugs by date:

Previous
From: Robert Haas
Date:
Subject: Re: BUG #6086: Segmentation fault
Next
From: "Greg Johnson"
Date:
Subject: BUG #6127: pg_restore failing: unexpected message type 0x58 during COPY from stdin