Re: DISTINCT ON troubles

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Brian Knox <laotse(at)aol(dot)net>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: DISTINCT ON troubles
Date: 2004-02-19 21:39:52
Message-ID: Pine.LNX.4.33.0402191439001.7167-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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);

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message scott.marlowe 2004-02-19 21:51:26 Re: DISTINCT ON troubles
Previous Message Brian Knox 2004-02-19 21:06:09 Re: DISTINCT ON troubles