to_char(date,'YYYYMMDD') bug - Mailing list pgsql-bugs

From Jord Tanner
Subject to_char(date,'YYYYMMDD') bug
Date
Msg-id 1036005851.1534.66.camel@gecko
Whole thread Raw
Responses Re: to_char(date,'YYYYMMDD') bug
List pgsql-bugs
Greetings,

It looks like to_char is unable to convert dates that fall in the range
of 01/01/1902 to 12/31/1969 (see below). I am running the Postgresql RPM
that is distributed with RH 8.0 (7.2.2.1). PGDATESTYLE is set to "SQL".
I find to_char behaves correctly on my RH 7.2 box with Postgresql 7.2
compiled from source.

Are there any known workarounds, or should I try compiling 7.2.3 from
source on my RH 8 box?

Jord Tanner
Independent Gecko Consultants
jord@nospam-indygecko.com



gbi=# select to_char('12/31/1969'::date, 'YYYYMMDD');
ERROR:  Unable to convert date to tm
gbi=# select to_char('01/01/1970'::date, 'YYYYMMDD');
 to_char
----------
 19700101
(1 row)

gbi=# select to_char('01/01/1900'::date, 'YYYYMMDD');
 to_char
----------
 19000101
(1 row)

gbi=# select to_char('01/01/1930'::date, 'YYYYMMDD');
ERROR:  Unable to convert date to tm
gbi=# select to_char('01/01/1920'::date, 'YYYYMMDD');
ERROR:  Unable to convert date to tm
gbi=# select to_char('01/01/1910'::date, 'YYYYMMDD');
ERROR:  Unable to convert date to tm
gbi=# select to_char('01/01/1901'::date, 'MMDDYYYY');
 to_char
----------
 01011901
(1 row)

gbi=# select to_char('01/01/1902'::date, 'MMDDYYYY');
ERROR:  Unable to convert date to tm

gbi=# select to_char('01/01/2000'::date, 'YYYYMMDD');
 to_char
----------
 20000101
(1 row)

gbi=# select version();

version
---------------------------------------------------------------------------------------------------------
 PostgreSQL 7.2.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2
20020903 (Red Hat Linux 8.0 3.2-7)
(1 row)

pgsql-bugs by date:

Previous
From: Neil Conway
Date:
Subject: Re: Bug #808: bison dies with max table size fatal error
Next
From: Tom Lane
Date:
Subject: Re: to_char(date,'YYYYMMDD') bug