Thread: TO_DATE behavior!
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
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/
> 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
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