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

From: دار الآثار للنشر والتوزيع-صنعاء Dar Alathar-Yemen <dar_alathar(at)hotmail(dot)com>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: رد: BUG #16419: wrong parsing BC year in to_date() function
Date: 2020-05-07 00:59:28
Message-ID: AM0PR03MB3570F99911704BFC77294DA1BFA50@AM0PR03MB3570.eurprd03.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Any one suppose that these functions return the same:
make_date(-1,1,1)
to_date('-1-01-01','yyyy-mm-dd')
But make_date will give 0001-01-01 BC
And to_date will give 0002-01-01 BC

If you think this is right behavior I think this must be documented

من: David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
‏‏تم الإرسال: Thursday, May 7, 2020 1:45:14 AM
إلى: dar_alathar(at)hotmail(dot)com <dar_alathar(at)hotmail(dot)com>; PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
‏‏الموضوع: Re: BUG #16419: wrong parsing BC year in to_date() function

On Wed, May 6, 2020 at 2:58 PM PG Bug reporting form <noreply(at)postgresql(dot)org<mailto: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<mailto: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.

من: David G. Johnston<mailto:david(dot)g(dot)johnston(at)gmail(dot)com>
إرسال: ‏الخميس,‏ ‏14 ‏رمضان,‏ ‏1441 ‏01:45 ‏ص
الموضوع: Re: BUG #16419: wrong parsing BC year in to_date() function

On Wed, May 6, 2020 at 2:58 PM PG Bug reporting form <noreply(at)postgresql(dot)org<mailto: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<mailto: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 David G. Johnston 2020-05-07 03:12:20 Re: BUG #16419: wrong parsing BC year in to_date() function
Previous Message David G. Johnston 2020-05-06 22:45:14 Re: BUG #16419: wrong parsing BC year in to_date() function

Browse pgsql-hackers by date

  From Date Subject
Next Message Andy Fan 2020-05-07 01:31:51 Re: [PATCH] Keeps tracking the uniqueness with UniqueKey
Previous Message Justin Pryzby 2020-05-07 00:31:14 Re: PG 13 release notes, first draft