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

From Bruce Momjian
Subject Re: age() function documentation
Date
Msg-id 200104111716.NAA05968@candle.pha.pa.us
Whole thread Raw
In response to Re: age() function documentation  (Peter Eisentraut <peter_e@gmx.net>)
List 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
days23: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(1row)
 

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

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


pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: pg_dump ordering problem (rc4)
Next
From: Peter Eisentraut
Date:
Subject: Re: RPM upgrade caveats going from a beta version to RC