Re: TO_DATE Function unintended behavior when month value is greater than 12

From: Pantelis Theodosiou <ypercube(at)gmail(dot)com>
To: Igor Neyman <ineyman(at)perceptron(dot)com>
Cc: naidu rongali <rongalinaidu(at)gmail(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: TO_DATE Function unintended behavior when month value is greater than 12
Date: 2018-03-01 19:40:10
Message-ID: CAE3TBxy-+2PG2+45puwf8A2FkgOfO9Y=vgDC=7VUzchn2GcHyg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Mar 1, 2018 at 7:28 PM, Igor Neyman <ineyman(at)perceptron(dot)com> wrote:

>
>
> *From:* naidu rongali [mailto:rongalinaidu(at)gmail(dot)com]
> *Sent:* Thursday, March 01, 2018 1:34 PM
> *To:* pgsql-bugs(at)postgresql(dot)org
> *Subject:* TO_DATE Function unintended behavior when month value is
> greater than 12
>
>
>
> *Attention: This email was sent from someone outside of Perceptron. Always
> exercise caution when opening attachments or clicking links from unknown
> senders or when receiving unexpected emails.*
>
>
>
> Hi,
>
> I noticed this behavior on recent release of PG database. It will be
> helpful to users, if this behavior is looked into.
>
>
>
> When executed below SQL, got unintended output when i expected it to throw
> error " not a valid month "
>
>
>
> SQL executed:
> select to_date('20171231','YYYYDDMM')
>
> result:
> 2019-07-17
>
>
>
>
>
> Thank you, Naidu
>
>
>
> I get this:
>
> ERROR: date/time field value out of range: "20171231" SQL state: 22008
>
>
>
> Regards,
>
> Igor Neyman
>
>
>

The error is thrown in version 10 but I get the wrong results in versions
9.3 to 9.6, both in the almost latest (9.3.21, 9.4.16, 9.5.11 and 9.6.7)
and today's releases (9.3.22, ..., 9.6.8)

Pantelis Theodosiou

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2018-03-01 19:43:22 Re: TO_DATE Function unintended behavior when month value is greater than 12
Previous Message Igor Neyman 2018-03-01 19:28:44 RE: TO_DATE Function unintended behavior when month value is greater than 12