Re: BUG #16419: wrong parsing BC year in to_date() function

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: dar_alathar(at)hotmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #16419: wrong parsing BC year in to_date() function
Date: 2020-05-06 22:45:14
Message-ID: CAKFQuwYPjq=UAHNZ6KtHuJPA8pmttV3X+imFYcBQqNUGWsCexg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Wed, May 6, 2020 at 2:58 PM PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference: 16419
> Logged by: Saeed Hubaishan
> Email address: dar_alathar(at)hotmail(dot)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.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message دار الآثار للنشر والتوزيع-صنعاء Dar Alathar-Yemen 2020-05-07 00:59:28 رد: BUG #16419: wrong parsing BC year in to_date() function
Previous Message PG Bug reporting form 2020-05-06 21:26:55 BUG #16419: wrong parsing BC year in to_date() function

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-05-06 22:56:40 Re: Another modest proposal for docs formatting: catalog descriptions
Previous Message David Steele 2020-05-06 22:39:01 Re: do {} while (0) nitpick