From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Bruce Momjian <bruce(at)momjian(dot)us> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-committers(at)postgresql(dot)org |
Subject: | Re: pgsql: Document that age() adds days, then full months. |
Date: | 2007-09-14 00:53:01 |
Message-ID: | 200709140053.l8E0r1w25825@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Bruce Momjian wrote:
> Tom Lane wrote:
> > momjian(at)postgresql(dot)org (Bruce Momjian) writes:
> > > Document that age() adds days, then full months.
> >
> > AFAICT, this documentation "improvement" is outright wrong.
>
> I am now thinking no documentation paragraph is even needed. We have to
> use the number of months in the earlier date or simple computations
> would not work like:
>
> test=> select age('2004-05-29', '2004-06-28');
> age
> ----------
> -30 days
> (1 row)
>
> The end of the earlier month is part of the interval between the two
> timestamps, while the end of the later month is not. Of course with a
> multi-months span there are more chances for variance, but we certainly
> should give the right answer for an interval < 1 month. I can just add
> a C comment.
I have updated the documentation to read:
Note there can be ambiguity in the <literal>months</> returned by
<function>age</> because different months have a different number of
days. <productname>PostgreSQL</>'s approach uses the month from the
earlier of the two dates when calculating partial months. For example,
<literal>age('2004-06-01', '2004-04-30')</> uses April to yield
<literal>1 mon 1 day</>, while using May would yield <literal>1 mon 2
days</> because May has 31 days, while April has only 30.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
From | Date | Subject | |
---|---|---|---|
Next Message | User Cunha17 | 2007-09-14 02:24:24 | snapshot - src: Even when the remote connection is local (remote=local), |
Previous Message | Bruce Momjian | 2007-09-14 00:52:46 | pgsql: Clarify age() 'months' calculation documentation. |