pgsql: Document that age() adds days, then full months.

Поиск
Список
Период
Сортировка
Искать

pgsql: Document that age() adds days, then full months.

От:
momjian@postgresql.org (Bruce Momjian)
Дата:
Log Message:
-----------
Document that age() adds days, then full months.

Modified Files:
--------------
    pgsql/doc/src/sgml:
        func.sgml (r1.382 -> r1.383)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/func.sgml.diff?r1=1.382&r2=1.383)

Re: pgsql: Document that age() adds days, then full months.

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
momjian@postgresql.org (Bruce Momjian) writes:
> Document that age() adds days, then full months.

AFAICT, this documentation "improvement" is outright wrong.

			regards, tom lane

Re: pgsql: Document that age() adds days, then full months.

От:
Bruce Momjian <bruce@momjian.us>
Дата:
Tom Lane wrote:
> momjian@postgresql.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.

-- 
  Bruce Momjian            http://momjian.us
  EnterpriseDB                               http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: pgsql: Document that age() adds days, then full months.

От:
Bruce Momjian <bruce@momjian.us>
Дата:
Bruce Momjian wrote:
> Tom Lane wrote:
> > momjian@postgresql.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 months</> returned by
   age</> because different months have a different number of
   days.  PostgreSQL</>'s approach uses the month from the
   earlier of the two dates when calculating partial months.  For example,
   age('2004-06-01', '2004-04-30')</> uses April to yield
   1 mon 1 day</>, while using May would yield 1 mon 2
   days</> because May has 31 days, while April has only 30.

-- 
  Bruce Momjian            http://momjian.us
  EnterpriseDB                               http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
FAQ