Strange behaviour of to_date() - Mailing list pgsql-hackers

From Mario Weilguni
Subject Strange behaviour of to_date()
Date
Msg-id 01041719461900.00830@wotan
Whole thread Raw
Responses Re: Strange behaviour of to_date()
List pgsql-hackers
I noticed a quite strange behaviour of to_char() in 7.0 and 7.1. It treats 
abbreveated forms of a date completely wrong. Example:

-- this one is ok
mario=# select to_date('04.01.2001', 'dd.mm.yyyy'); to_date
------------2001-01-04

-- this is completly wrong, but NO error raised
mario=# select to_date('4.01.2001', 'dd.mm.yyyy'); to_date
------------0001-01-04

-- completly wrong as well
mario=# select to_date('4.1.2001', 'dd.mm.yyyy'); to_date
------------0001-01-04


IMO to_date() should either recognize the date, even if shorter than the mask 
(Oracle compatible), or raise an error. Currently it gives completly wrong 
results, which is the worst option.

I tried to fix this myself, but I'm lost within backend/utils/adt/formatting.c


-- 
===================================================Mario Weilguni                               KPNQwest Austria GmbH
 Senior Engineer Web Solutions                         Nikolaiplatz 4
 tel: +43-316-813824                                8020 graz, austria
 fax: +43-316-813824-26                    http://www.kpnqwest.at
 e-mail: mario.weilguni@kpnqwest.com
===================================================


pgsql-hackers by date:

Previous
From: "Mikheev, Vadim"
Date:
Subject: RE: AW: timeout on lock feature
Next
From: ncm@zembu.com (Nathan Myers)
Date:
Subject: Re: Another news story in need of 'enlightenment'