From: | "Pelle Johansson" <pelle(at)morth(dot)org> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #3431: age() gets the days wrong |
Date: | 2007-07-06 08:44:08 |
Message-ID: | 200707060844.l668i89w097496@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers pgsql-patches |
The following bug has been logged online:
Bug reference: 3431
Logged by: Pelle Johansson
Email address: pelle(at)morth(dot)org
PostgreSQL version: 8.2.3
Operating system: Linux 2.6
Description: age() gets the days wrong
Details:
This might be a known issue but i couldn't find it reported before...
The age() function seem to work by first counting months until less than a
month remains to to the second argument, then counting days left. This
doesn't give the correct result, as shown by this example:
# select column1, age(column1, '2006-11-02'), date '2006-11-02' +
age(column1, '2006-11-02') from (values ('2007-01-31'::date),
('2007-02-01')) as alias;
column1 | age | ?column?
------------+----------------+---------------------
2007-01-31 | 2 mons 29 days | 2007-01-31 00:00:00
2007-02-01 | 2 mons 29 days | 2007-01-31 00:00:00
(2 rows)
For the second row, the age should be '2 mons 30 days', which is what you
need to add to '2006-11-02' to get back to '2007-02-01'.
The - operator does not have this problem, so it can be used as a
workaround, but not in all situations.
From | Date | Subject | |
---|---|---|---|
Next Message | Gurjeet Singh | 2007-07-06 08:53:28 | Re: BUG #3430: Case Sensitive Table Names |
Previous Message | Stéphane Schildknecht | 2007-07-06 07:38:44 | Re: BUG #3430: Case Sensitive Table Names |
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2007-07-06 09:55:28 | Re: Bgwriter strategies |
Previous Message | Greg Smith | 2007-07-06 08:13:35 | Re: Bgwriter strategies |
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2007-07-06 10:24:52 | Re: Compile error with MSVC |
Previous Message | Peter Eisentraut | 2007-07-06 07:54:02 | Re: script binaries renaming |