From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | szx9231(at)gmail(dot)com, PostgreSQL Bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #16216: the result of to_date function with negative year number not same as BC year number |
Date: | 2020-01-17 14:17:34 |
Message-ID: | alpine.DEB.2.21.2001171503400.31891@pseudo |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hello,
> example:
> postgres=# select to_date('-120', 'yyyy');
> to_date
> ---------------
> 0121-01-01 BC
> (1 row)
>
> postgres=# select to_date('120bc', 'yyyybc');
> to_date
> ---------------
> 0120-01-01 BC
> (1 row)
>
> I think -120 means 120bc, however, the output is 121bc not 120bc.
ISTM that the documentation does not say that -120 is supported as meaning
BC.
Given that there are no year 0 (zero was invented much later), history
skips form year -1 to year 1. If -120 means in the implementation "year as
an integer", then skipping zero would mean that it indeed represents year
121 BC, i.e. 120 years before "Jan 1, 1 AD". So there is a logic.
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'll try to have a look over the week-end.
--
Fabien.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-01-17 14:59:42 | Re: BUG #16216: the result of to_date function with negative year number not same as BC year number |
Previous Message | Heikki Linnakangas | 2020-01-17 12:53:11 | Re: REINDEX CONCURRENTLY unexpectedly fails |