Re: BUG #16419: wrong parsing BC year in to_date() function - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #16419: wrong parsing BC year in to_date() function
Date
Msg-id CAKFQuwYPjq=UAHNZ6KtHuJPA8pmttV3X+imFYcBQqNUGWsCexg@mail.gmail.com
Whole thread Raw
In response to BUG #16419: wrong parsing BC year in to_date() function  (PG Bug reporting form <noreply@postgresql.org>)
Responses رد: BUG #16419: wrong parsing BC year in to_date() function  (دار الآثار للنشر والتوزيع-صنعاء Dar Alathar-Yemen <dar_alathar@hotmail.com>)
List pgsql-bugs
On Wed, May 6, 2020 at 2:58 PM PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      16419
Logged by:          Saeed Hubaishan
Email address:      dar_alathar@hotmail.com
PostgreSQL version: 12.2
Operating system:   Windows 10x64
Description:       

select to_date('-1-01-01','yyyy-mm-dd');
will get
0002-01-01 BC

Yep...

select to_date('1','YYYY')::text; // Year 1 AD
select to_date('0','YYYY')::text; // Year 1 BC (there is no year zero)
select to_date('-1','YYYY')::text; // Year 2 BC

to_date tries very hard to not error - if you need to use it make sure your data conforms to the format you specify.

David J.

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #16419: wrong parsing BC year in to_date() function
Next
From: دار الآثار للنشر والتوزيع-صنعاء Dar Alathar-Yemen
Date:
Subject: رد: BUG #16419: wrong parsing BC year in to_date() function