Re: age() function documentation - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: age() function documentation
Date
Msg-id Pine.LNX.4.30.0104121928450.1148-100000@peter.localdomain
Whole thread Raw
In response to Re: age() function documentation  (Thomas Lockhart <lockhart@alumni.caltech.edu>)
List pgsql-hackers
Thomas Lockhart writes:

> Typical date/time arithmetic resolves to an absolute time or interval.
> In those cases, *qualitative* quantities such as years and months are
> resolved to a specific absolute interval at the time of calculation.
>
> The age() functions *preserve* the qualitative fields year and month. So
> you see the difference in results:
>
> lockhart=# select age('today', '1957-06-13');
> -------------------------
>  43 years 9 mons 28 days
>
> lockhart=# select timestamp 'today' - timestamp '1957-06-13';
> ------------
>  16008 days

Perhaps age() could be documented along the lines of:

Calculates the difference between the arguments and expresses the
resulting interval in terms of years, months and possibly smaller units.
Ordinary timestamp subtraction is different from age() because it
expresses its result only in days and smaller units.

Plus a contrasting example, such as the above.

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



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: age() function documentation
Next
From: Peter Eisentraut
Date:
Subject: Re: AW: AW: AW: Truncation of char, varchar types