Leslie S Satenstein <lsatenst...@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 -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs