Re: BUG #17155: Casting to type date

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: 66666666nikita(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17155: Casting to type date
Date: 2021-08-20 13:36:16
Message-ID: 1851838.1629466576@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> In the previous version 12.6, the date cast is handled without errors, but
> in version 12.8 this generates an error
> SELECT '20.08.2021'::date

Nothing has changed in that area in quite some time. I don't
have a 12.6 installation immediately at hand, but I did find 12.2
laying about on my laptop, and it behaves the same way as 12.8:

$ psql postgres
psql (12.2)
Type "help" for help.

postgres=# SELECT '20.08.2021'::date;
ERROR: date/time field value out of range: "20.08.2021"
LINE 1: SELECT '20.08.2021'::date;
^
HINT: Perhaps you need a different "datestyle" setting.

The HINT's recommendation is accurate:

postgres=# set datestyle = dmy;
SET
postgres=# SELECT '20.08.2021'::date;
date
------------
2021-08-20
(1 row)

So I suspect you forgot to transfer your datestyle setting to the
new installation.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sunil Choudhary 2021-08-20 13:36:53 Urgent Support Need
Previous Message PG Bug reporting form 2021-08-20 11:19:04 BUG #17155: Casting to type date