From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Abraham, Danny" <danny_abraham(at)bmc(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: date function bug |
Date: | 2019-10-23 14:44:52 |
Message-ID: | 21348.1571841892@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Abraham, Danny" <danny_abraham(at)bmc(dot)com> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2019-10-23 14:46:03 | Re: date function bug |
Previous Message | Kevin Brannen | 2019-10-23 14:44:21 | RE: date function bug |