Re: age() function documentation

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: lockhart(at)fourpalms(dot)org, Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: age() function documentation
Date: 2001-04-11 17:16:44
Message-ID: 200104111716.NAA05968@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Thomas Lockhart writes:
>
> > Why do you have a problem with the age() function? It *does* behave
> > differently than date subtraction, as explicitly mentioned in the docs
> > (preserving years, etc etc).
>
> As you see in one of the examples I posted, it does not preserve years and
> months. What exactly does that mean anyway? Simple subtraction also
> preserves years and months, as I see it.

From your URL email, this one seems to work:

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

This one did not:

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

and this one is less than one month:

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

I will admit age() is a little confusing, but it seems to work as
intended.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-04-11 17:43:44 Re: RPM upgrade caveats going from a beta version to RC
Previous Message Philip Warner 2001-04-11 17:12:38 Re: pg_dump ordering problem (rc4)