Re: How Many Years have Passed? - Mailing list pgsql-general

From Thomas Lockhart
Subject Re: How Many Years have Passed?
Date
Msg-id 3C229188.EF5C9937@fourpalms.org
Whole thread Raw
In response to Re: How Many Years have Passed?  ("Greg Sabino Mullane" <greg@turnstep.com>)
List 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

pgsql-general by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: How Many Years have Passed?
Next
From: Gurudutt
Date:
Subject: Re: