How Many Years have Passed?

From: "Ian Harding" <ianh(at)tpchd(dot)org>
To: <pgsql-general(at)postgresql(dot)org>
Subject: How Many Years have Passed?
Date: 2001-12-19 21:03:26
Message-ID: sc209067.069@mail.tpchd.org
Views: Raw Message | Whole Thread | 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.

Is the only way to do that to do something like checking the julian day first to see if the second one is higher (i.e. it's past my birthday), then doing date_part('year', foo) - date_part('year', bar) and adjusting for whether my birthday has passed?

Thanks!

Ian A. Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
(253) 798-3549
mailto: iharding(at)tpchd(dot)org

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joseph Shraibman 2001-12-19 21:03:51 sql scripts
Previous Message Tom Lane 2001-12-19 19:02:32 Re: Can't use subselect in check constraint