pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: szx9231@gmail.com, PostgreSQL Bugs <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #16216: the result of to_date function with negative year number not same as BC year number
Date: Fri, 17 Jan 2020 16:15:15 +0100 (CET)
Message-ID: <alpine.DEB.2.21.2001171609210.31891@pseudo> (raw)
In-Reply-To: <26771.1579273182@sss.pgh.pa.us>
References: <16216-68da08087f3aeb78@postgresql.org>
	<alpine.DEB.2.21.2001171503400.31891@pseudo>
	<26771.1579273182@sss.pgh.pa.us>


>> 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.

I agree.

> If we do anything about this, my vote would be to throw an error for 
> zero or negative year field.

Yep, being stricter.

> OTOH, the point of to_date is mostly not to throw an error, so maybe we 
> should leave it be.

I'll think about it.

>> 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.

Hmmm. Ok, I see.

If I write a fuzzy "31/12/01", I'm pretty okay with 2001-12-31. but if I 
write '1 AD', I would expect '1 AD'.

-- 
Fabien.

view thread (5+ messages)  latest in thread

Message-ID: <alpine.DEB.2.21.2001171609210.31891@pseudo>
Permalink:  ../alpine.DEB.2.21.2001171609210.31891@pseudo/
Also on:    postgresql.org/message-id/alpine.DEB.2.21.2001171609210.31891@pseudo

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: coelho@cri.ensmp.fr, tgl@sss.pgh.pa.us
  Subject: Re: BUG #16216: the result of to_date function with negative year number not same as BC year number
  In-Reply-To: <alpine.DEB.2.21.2001171609210.31891@pseudo>
  References: <16216-68da08087f3aeb78@postgresql.org> <alpine.DEB.2.21.2001171503400.31891@pseudo> <26771.1579273182@sss.pgh.pa.us> <alpine.DEB.2.21.2001171609210.31891@pseudo>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox