Converting old dates to chars - Mailing list pgsql-novice

From Francesco Marchetti-Stasi
Subject Converting old dates to chars
Date
Msg-id 3F0A9E12.4477.8AFB0C@localhost
Whole thread Raw
List pgsql-novice
Hello everybody,

I am using the stock postgresql 7.2.2 on a Red Hat 8.0 (not my choice of a distribution, mind
you, but I'm already lucky to be able to use _that_ at work...). I've been using it for a
while, also. Recently my users inserted a few rather old documents (yes, we do have laws as old
as the dates which you will see below in Italy, which explains a lot of things...), and I
stumbled into a very funny behaviour, which I traced to the following:

intranet=# select to_char(to_date('1865-03-20','YYYY-MM-DD'),'DD/MM/YYYY');
       to_char
------------
 20/03/1865
(1 row)

intranet=# select to_char(to_date('1924-05-23','YYYY-MM-DD'),'DD/MM/YYYY');
ERROR:  Unable to convert date to tm

What I find funny here is that 1865 is supported, but 1924 is not... actually, the first 70
years of last century give problems (I didn't check the whole range of supported years, though).

I have "patched" my scripts replacing "to_char(data)" with "extract(day from
data)||'/'||extract(month from data)||'/'||extract(year from data)", but it's really ugly...
Any better suggestion, anybody?

("Upgrade to postgres x.y.z" is welcome, but I won't be able to do it before the holydays...)

Thanks for any reply,
Francesco.


pgsql-novice by date:

Previous
From: Volker Krey
Date:
Subject: inheritance
Next
From: Martin Foster
Date:
Subject: Re: [PERFORM] Extreme high load averages