From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | 正华吕 <kainwen(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Question on cast string to date |
Date: | 2022-05-10 04:36:08 |
Message-ID: | CAFj8pRD8VvT7jvxWvgt87bHYLJM0Yu9iQaPteD9tqf-ecRTapQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
út 10. 5. 2022 v 6:28 odesílatel 正华吕 <kainwen(at)gmail(dot)com> napsal:
> Hi,
>
> I test the following SQL in pg15dev (seems same behavior as the
> previous version).
>
> select '2020701'::date;
> date
> ------------
> 0202-07-01
> (1 row)
>
> At the first glance, the result seems quite strange.
>
> Go through the code, postgres use date_in to do the cast, and firstly
> use last 2 chars to
> get the day, and the 2 chars to get the month, and all remaining chars
> as year.
>
> The question here is: should we throw error for such input? Or what
> standard postgres is
> using to cast such kind of string?
>
This is ISO format
https://en.wikipedia.org/wiki/ISO_8601
https://postgresqlco.nf/doc/en/param/DateStyle/
Regards
Pavel
>
> Thanks.
>
From | Date | Subject | |
---|---|---|---|
Next Message | Ian Lawrence Barwick | 2022-05-10 04:38:23 | Re: Question on cast string to date |
Previous Message | 正华吕 | 2022-05-10 04:28:35 | Question on cast string to date |