Search Postgresql Archives

Re: date function bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Abraham, Danny" <danny_abraham@xxxxxxx> writes:
> The function "to_date" does not fail illegal values.
> Is this a known bug?

No, it's a feature, because the point of to_date() is to parse strings
that would be rejected or misinterpreted by the regular date input
function.  If you want tighter error checking and your input is supposed
to follow a common format, just cast the string to date.

regression=# select '2018100X'::date;
ERROR:  invalid input syntax for type date: "2018100X"
LINE 1: select '2018100X'::date;
               ^
regression=# select '20181501'::date;
ERROR:  date/time field value out of range: "20181501"
LINE 1: select '20181501'::date;
               ^
HINT:  Perhaps you need a different "datestyle" setting.
regression=# select '20181001'::date;
    date    
------------
 2018-10-01
(1 row)

			regards, tom lane





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux