Re: Question on cast string to date

Поиск
Список
Период
Сортировка
От Ian Lawrence Barwick
Тема Re: Question on cast string to date
Дата
Msg-id CAB8KJ=gFj0EsNCGfzZ_LeTPQnVA==ZYXMVs6iXqZC__t=+hXLA@mail.gmail.com
обсуждение исходный текст
Ответ на Question on cast string to date  (正华吕 <kainwen@gmail.com>)
Список pgsql-general
2022年5月10日(火) 13:28 正华吕 <kainwen@gmail.com>:
>
> 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-8601 format, see here for a list of possible input formats:

  https://www.postgresql.org/docs/current/datatype-datetime.html#id-1.5.7.13.18.5


Regards

Ian Barwick

--
EnterpriseDB: https://www.enterprisedb.com



В списке pgsql-general по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: Question on cast string to date
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Question on cast string to date