Re: BUG #16419: wrong parsing BC year in to_date() function
David G. Johnston <david.g.johnston@gmail.com>
From: "David G. Johnston" <david.g.johnston@gmail.com>
To: dar_alathar@hotmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2020-05-06T22:45:14Z
Lists: pgsql-bugs, pgsql-hackers
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.
Commits
-
Fix handling of BC years in to_date/to_timestamp.
- db96be24ce32 10.15 landed
- c5232dca8d1b 12.5 landed
- b0fe0b022f80 11.10 landed
- 99fd38c02299 13.1 landed
- 489c9c3407cb 14.0 landed
- 4857e6fe16c2 9.5.24 landed
- 19e7982681df 9.6.20 landed
-
Fix make_timestamp[tz] to accept negative years as meaning BC.
- a094c8ff5352 14.0 landed
-
doc: PG 13 relnotes, update TOAST item to mention decompression
- fb544735f114 13.0 cited