TO_DATE behavior!

Started by Gevik Babakhaniabout 18 years ago4 messageshackers
Jump to latest
#1Gevik Babakhani
pgdev@xs4all.nl

I would like to have your opinion about the following behavior of TO_DATE.
Is this correct or a hidden feature?

case:
'mon 21-feb-2008' is obviously a bad date. It should be 'thu 21-feb-2008'

test:
testdb=# select to_date('mon 21-feb-2008','dy dd-mon-yyyy');
to_date
------------
2008-02-21
(1 row)

No complains there!(?)

The opposite query results the correct date.

test:
testdb=# select to_char(to_date('mon 21-feb-2008','dy dd-mon-yyyy'),'dy
dd-mon-yyyy');
to_char
-----------------
thu 21-feb-2008
(1 row)

Regards,
Gevik

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Gevik Babakhani (#1)
Re: TO_DATE behavior!

Gevik Babakhani wrote:

I would like to have your opinion about the following behavior of TO_DATE.
Is this correct or a hidden feature?

There are quite a few complaints in the archive about to_date's incorrect or
questionable behavior. I'm sure this is one of them. This code needs a
general, systematic review.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#3Gevik Babakhani
pgdev@xs4all.nl
In reply to: Peter Eisentraut (#2)
Re: TO_DATE behavior!

There are quite a few complaints in the archive about
to_date's incorrect or questionable behavior. I'm sure this
is one of them. This code needs a general, systematic review.

I am working on a todo item. I'll report and fix anything I encounter there.

Regards,
Gevik

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#2)
Re: TO_DATE behavior!

Peter Eisentraut <peter_e@gmx.net> writes:

Gevik Babakhani wrote:

I would like to have your opinion about the following behavior of TO_DATE.
Is this correct or a hidden feature?

There are quite a few complaints in the archive about to_date's incorrect or
questionable behavior. I'm sure this is one of them. This code needs a
general, systematic review.

to_date has always been impressively lax about error-checking its input.
While I wouldn't object to tightening that up, surely checking a
weekday name against the rest of the date should be very far down the
priority list of checks to make.

regards, tom lane