Re: Mysteries of the future

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: y(dot)saburov(at)gmail(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Mysteries of the future
Date: 2024-04-11 14:34:14
Message-ID: CAKFQuwbfU8QuQKo2yYE78-rU+5vS9NF1Lmu+T==UKA6j2_3O+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Thu, Apr 11, 2024 at 7:20 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> PG Doc comments form <noreply(at)postgresql(dot)org> writes:
> > SELECT to_date('20000-1131', 'YYYY-MMDD');
> > ERROR: 22008: date/time field value out of range: "20000-1131"
>
> What exactly do you find wrong with that? November doesn't have
> 31 days.
>
> Sure, we could have a discussion about the probability of the
> Gregorian calendar still being in use 18000 years from now,
> but it doesn't seem very profitable. What else do you want
> to use?
>

The request is to fix our documentation to use a valid date for the example
in the paragraph that describes the separator requirement for years greater
than 4 digits.

In to_timestamp and to_date, the YYYY conversion has a restriction when
processing years with more than 4 digits. You must use some non-digit
character or template after YYYY, otherwise the year is always interpreted
as 4 digits. For example (with the year 20000): to_date('200001131',
'YYYYMMDD') will be interpreted as a 4-digit year; instead use a non-digit
separator after the year, like to_date('20000-1131', 'YYYY-MMDD') or
to_date('20000Nov31', 'YYYYMonDD').

David J.

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2024-04-11 14:47:03 Re: Mysteries of the future
Previous Message Tom Lane 2024-04-11 14:20:38 Re: Mysteries of the future