X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A67FDD1E136 for ; Thu, 19 Feb 2004 21:48:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 34888-05 for ; Thu, 19 Feb 2004 17:48:42 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 5422FD1E12D for ; Thu, 19 Feb 2004 17:48:36 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1JLkh7k018627; Thu, 19 Feb 2004 14:46:43 -0700 (MST) Date: Thu, 19 Feb 2004 14:39:52 -0700 (MST) From: "scott.marlowe" To: Brian Knox Cc: Subject: Re: DISTINCT ON troubles In-Reply-To: <40352541.8040507@aol.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/291 X-Sequence-Number: 16981 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);