From: Tom Lane <tgl@sss.pgh.pa.us>
To: Leslie S Satenstein <lsatenstein@yahoo.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Postgres documentation <pgsql-docs@postgresql.org>
Subject: Re: Some comments about Julian Dates and possible bug. Please provide feedback.
Date: Wed, 29 Dec 2010 12:56:12 -0500
Message-ID: <25438.1293645372@sss.pgh.pa.us> (raw)
In-Reply-To: <489318.10800.qm@web110704.mail.gq1.yahoo.com>
References: <489318.10800.qm@web110704.mail.gq1.yahoo.com>
Leslie S Satenstein <lsatenstein@yahoo.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
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 using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: tgl@sss.pgh.pa.us, lsatenstein@yahoo.com, robertmhaas@gmail.com
Subject: Re: Some comments about Julian Dates and possible bug. Please provide feedback.
In-Reply-To: <25438.1293645372@sss.pgh.pa.us>
* 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