Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id B257E1337B56 for ; Wed, 29 Dec 2010 13:56:20 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 06318-07 for ; Wed, 29 Dec 2010 17:56:13 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 749FB1337B50 for ; Wed, 29 Dec 2010 13:56:13 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id oBTHuCLx025439; Wed, 29 Dec 2010 12:56:12 -0500 (EST) To: Leslie S Satenstein cc: Robert Haas , Postgres documentation Subject: Re: Some comments about Julian Dates and possible bug. Please provide feedback. In-reply-to: <489318.10800.qm@web110704.mail.gq1.yahoo.com> References: <489318.10800.qm@web110704.mail.gq1.yahoo.com> Comments: In-reply-to Leslie S Satenstein message dated "Wed, 29 Dec 2010 09:38:36 -0800" Date: Wed, 29 Dec 2010 12:56:12 -0500 Message-ID: <25438.1293645372@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/52 X-Sequence-Number: 6288 Leslie S Satenstein 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