Re: to_char() accepting invalid dates? - Mailing list pgsql-sql

From Thomas Kellerer
Subject Re: to_char() accepting invalid dates?
Date
Msg-id j03psc$aof$1@dough.gmane.org
Whole thread Raw
In response to Re: to_char() accepting invalid dates?  (Bruce Momjian <bruce@momjian.us>)
Responses Re: to_char() accepting invalid dates?  (Bruce Momjian <bruce@momjian.us>)
List pgsql-sql
Bruce Momjian, 19.07.2011 00:02:
>>>> postgres=>   select to_date('20110231', 'yyyymmdd');
>>>>
>>>>      to_date
>>>> ------------
>>>>     2011-03-03
>>>> (1 row)
>>>>
>>>> is there a way to have to_date() raise an exception in such a case?
>>>
>>> it's possible the odd behaviour you get is required by some standard.
>>
>> That would be *very* odd indeed.
>>
>>
>>>    jasen=# select '20110303'::date;
>> Thanks for the tip, this was more a question regarding _why_ to_char() behaves this way.
>
> Well, to_char() is based on Oracle's to_char().  How does Oracle handle
> such a date?

Oracle throws an error for the above example:

SQL> select to_date('20110231', 'YYYYMMDD') from dual;
select to_date('20110231', 'YYYYMMDD') from dual               *
ERROR at line 1:
ORA-01839: date not valid for month specified

SQL>


Regards
Thomas
 




pgsql-sql by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: to_char() accepting invalid dates?
Next
From: "Igor Neyman"
Date:
Subject: Re: to_char() accepting invalid dates?