Converting old dates to chars

From: "Francesco Marchetti-Stasi" <f(dot)marchettistasi(at)autoritalavoripubblici(dot)it>
To: pgsql-novice(at)postgresql(dot)org
Subject: Converting old dates to chars
Date: 2003-07-08 08:33:54
Message-ID: 3F0A9E12.4477.8AFB0C@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Browse pgsql-novice by date

  From Date Subject
Next Message Harry Broomhall 2003-07-08 09:06:03 Re: Problems with arrays
Previous Message Herbie McDuck 2003-07-08 05:57:45 OK..time for STUPID to say somthing