I gave up on the sql and used Date::Calc from Perl. Thanks for your answer anyway.
scott.marlowe wrote:
On Thu, 19 Feb 2004, Brian Knox wrote:
( sorry if this is a repeat, my mail server is being wonky today )
I'm looking for a way, within SQL, given a starting date and an ending date, to get back the number of months between the start and end date. If I "SELECT end_date - start_date", I get back an interval in days; I need months.
Maybe date_part?
select date_part('month','2004-08-02 12:00:00'::timestamp) - date_part('month','2004-05-01 12:00:00'::timestamp);
---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster