| From: | Thomas Lockhart <lockhart(at)fourpalms(dot)org> | 
|---|---|
| To: | Greg Sabino Mullane <greg(at)turnstep(dot)com> | 
| Cc: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: How Many Years have Passed? | 
| Date: | 2001-12-21 01:34:00 | 
| Message-ID: | 3C229188.EF5C9937@fourpalms.org | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
> > I have checked the FAQ and other sources and learned that the difference
> > between two dates is the integer number of days.  I want to know how many
> > years are between those two dates.
thomas=# select age(date 'today', date '1980-01-01'),
thomas-# extract(year from age(date 'today', date '1980-01-01')); 
           age            | date_part 
--------------------------+-----------
 21 years 11 mons 20 days |        21
Is this close to what you want? The nice thing about the age() function
is that it preserves the qualitative units of month and year.
- Thomas
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2001-12-21 03:54:18 | Re: TOAST performance (was Re: [GENERAL] Delete Performance) | 
| Previous Message | Greg Sabino Mullane | 2001-12-21 00:33:26 | Re: How Many Years have Passed? |