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

From Peter Eisentraut
Subject Re: age() function documentation
Date
Msg-id Pine.LNX.4.30.0104121739300.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:

> 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
>
> In the case for the DATE type, the result is an integer value (not an
> interval) which I believe was done intentionally but I'm not recalling
> exactly why; I can research it if necessary:
>
> lockhart=# select date 'today' - date '1957-06-13';
> ----------
>     16008
>
> returns the number of days (which is also an absolute, quantitative
> time).

ISTM that this is more a result of

a) timestamp subtraction not implemented per spec

b) date substraction not implemented at all (it does date - integer)

c) implicit type conversions running wild

d) intervals not implemented per spec

(spec == SQL).  Lots of fun projects here... ;-)

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



pgsql-hackers by date:

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