age() function not to spec, date subtraction? - Mailing list pgsql-hackers

From Peter Eisentraut
Subject age() function not to spec, date subtraction?
Date
Msg-id Pine.LNX.4.30.0102162108560.1009-100000@peter.localdomain
Whole thread Raw
List pgsql-hackers
The age() function is documented as "Calculate time difference while
retaining year/month fields", but it doesn't seem to do anything different
from a plain date subtraction with a few time zone problems added in:

select age(date '1999-05-17', date '1957-06-13');             age
-------------------------------41 years 11 mons 3 days 23:00
(1 row)

peter=# select age(date '1999-05-17', date '1999-06-13');  age
-----------27 days
(1 row)

But then again, date subtraction has seen better days, too:

peter=# select date '1999-08-13' - date '1989-06-13';?column?
----------    3713
(1 row)

peter=# select date '1999-08-13' - date '1999-06-13';?column?
----------      61
(1 row)

As opposed to:

peter=# select timestamp '1999-08-13' - timestamp '1999-06-13';?column?
----------61 days
(1 row)

SQL sez date - date returns interval, btw.

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Backup from within Postgres
Next
From: Thomas Lockhart
Date:
Subject: Re: extract vs date_part