Re: BUG #16216: the result of to_date function with negative year number not same as BC year number

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #16216: the result of to_date function with negative year number not same as BC year number
Дата
Msg-id 26771.1579273182@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #16216: the result of to_date function with negative yearnumber not same as BC year number  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: BUG #16216: the result of to_date function with negative yearnumber not same as BC year number  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-bugs
Fabien COELHO <coelho@cri.ensmp.fr> writes:
>> postgres=# select to_date('-120', 'yyyy');
>> to_date
>> ---------------
>> 0121-01-01 BC
>> (1 row)

> ISTM that the documentation does not say that -120 is supported as meaning 
> BC.

Indeed it does not.  The behavior is "correct" in terms of our internals,
as you say, but I'm a bit distressed to find that we're exposing the
internals this much.  If we do anything about this, my vote would be
to throw an error for zero or negative year field.  OTOH, the point of
to_date is mostly not to throw an error, so maybe we should leave it be.

> BTW I found another oddity while trying strange date patterns:
>    sql> SELECT DATE 'Jan 1, 0001 AD';
>    # 0001-01-01
> But:
>    sql> SELECT DATE 'Jan 1, 1 AD';
>    # 2001-01-01 # WT*?

I'm pretty sure that's intentional; if you specify two or fewer
year digits, a year between 1970 and 2069 is presumed to be meant.

            regards, tom lane



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

Предыдущее
От: Fabien COELHO
Дата:
Сообщение: Re: BUG #16216: the result of to_date function with negative yearnumber not same as BC year number
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #16217: ECPG call interface && filename of the foo.pgc file for logging