Potential to_date(string, string) function malfunction

Started by Pavel Plevaover 6 years ago3 messagesbugs
Jump to latest
#1Pavel Pleva
pavel.pleva@gmail.com

Hi,

I'd like to report you in my opinion weird behaviour of function
to_date(string, string). According to specs using format 'YYYY-MM-DD' in
months portion it should tolerate 01-12 and in days portion 01-31. But
if you try "SELECT to_date('2019-30-50', 'YYYY-MM-DD') instead of
throwing error it outputs "2021-07-23".

This is output of 'SELECT version();' on our system: "PostgreSQL 9.4.23
on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red
Hat 4.8.5-36), 64-bit"

Have a nice day!

Pavel Pleva

Attachments:

ToDatePostgreSql.pngimage/png; name=ToDatePostgreSql.pngDownload
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Pavel Pleva (#1)
Re: Potential to_date(string, string) function malfunction

Pavel Pleva <pavel.pleva@gmail.com> writes:

I'd like to report you in my opinion weird behaviour of function
to_date(string, string). According to specs using format 'YYYY-MM-DD' in
months portion it should tolerate 01-12 and in days portion 01-31. But
if you try "SELECT to_date('2019-30-50', 'YYYY-MM-DD') instead of
throwing error it outputs "2021-07-23".

This is output of 'SELECT version();' on our system: "PostgreSQL 9.4.23
on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red
Hat 4.8.5-36), 64-bit"

PG v10 and later throw an error for this.

regards, tom lane

#3Pavel Pleva
pavel.pleva@gmail.com
In reply to: Tom Lane (#2)
Re: Potential to_date(string, string) function malfunction

Thanks for reply, don't have access to PG v10 so good to know.

Best regards

Pavel Pleva

Dne 08. 10. 19 v 17:38 Tom Lane napsal(a):

Show quoted text

Pavel Pleva <pavel.pleva@gmail.com> writes:

I'd like to report you in my opinion weird behaviour of function
to_date(string, string). According to specs using format 'YYYY-MM-DD' in
months portion it should tolerate 01-12 and in days portion 01-31. But
if you try "SELECT to_date('2019-30-50', 'YYYY-MM-DD') instead of
throwing error it outputs "2021-07-23".
This is output of 'SELECT version();' on our system: "PostgreSQL 9.4.23
on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red
Hat 4.8.5-36), 64-bit"

PG v10 and later throw an error for this.

regards, tom lane