Re: DISTINCT ON troubles - Mailing list pgsql-sql

From scott.marlowe
Subject Re: DISTINCT ON troubles
Date
Msg-id Pine.LNX.4.33.0402191451120.7643-100000@css120.ihs.com
Whole thread Raw
In response to Re: DISTINCT ON troubles  ("scott.marlowe" <scott.marlowe@ihs.com>)
List pgsql-sql
On Thu, 19 Feb 2004, 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);

Note that I think you need a +1 at the end of that...



pgsql-sql by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: DISTINCT ON troubles
Next
From: Tom Lane
Date:
Subject: Re: Distributed Transactions