From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: to_char() accepting invalid dates? |
Date: | 2011-07-20 01:03:44 |
Message-ID: | 201107200103.p6K13ix10517@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Thomas Kellerer wrote:
> 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>
OK, it's a bug then. Let me see if I can find a fix for it.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2011-07-20 07:15:15 | Re: to_char() accepting invalid dates? |
Previous Message | Igor Neyman | 2011-07-19 14:09:10 | Re: to_char() accepting invalid dates? |