From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Leslie S Satenstein <lsatenstein(at)yahoo(dot)com> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Postgres documentation <pgsql-docs(at)postgresql(dot)org> |
Subject: | Re: Some comments about Julian Dates and possible bug. Please provide feedback. |
Date: | 2010-12-29 17:56:12 |
Message-ID: | 25438.1293645372@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs |
Leslie S Satenstein <lsatenstein(at)yahoo(dot)com> writes:
>> I tested and found the algorithm in Postgres to have
>> the day before January 1,0001 calculating as December
>> 31,0000 even though the world calculates the day before
>> January 1,0001 as December 31,-0001.
>
>> 2) Is the algorithm in Postgres correct? I think
>> not, as the calculations for the difference in days between
>> January 1, 0001 and December 31,-0001 is not 367 days, but
>> just the value 1.
This is not a bug, it's just failure to understand the conventions used
internally. If you did the calculations at the SQL level you would get
the right answers:
regression=# select '0001-01-01'::date - 1;
?column?
---------------
0001-12-31 BC
(1 row)
regression=# select '0001-01-01'::date - '0001-12-31 BC'::date;
?column?
----------
1
(1 row)
Internally we represent 1 BC as "year zero", 2 BC as "year -1", etc,
but this isn't a problem from users' perspective.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2010-12-30 04:18:23 | Re: Words missing in the following txt |
Previous Message | Tom Lane | 2010-12-29 17:46:02 | Re: Words missing in the following txt |