The following bug has been logged online:
Bug reference: 6126
Logged by: Artem Andreev
Email address: artem(at)oktetlabs(dot)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