Re: age() function documentation

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: <lockhart(at)fourpalms(dot)org>, Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: age() function documentation
Date: 2001-04-12 17:32:40
Message-ID: Pine.LNX.4.30.0104121928450.1148-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net http://yi.org/peter-e/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-04-12 17:43:01 Re: AW: AW: AW: Truncation of char, varchar types
Previous Message Peter Eisentraut 2001-04-12 17:26:05 Re: age() function documentation