pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brian Knox <laotse@aol.net>
To: scott.marlowe <scott.marlowe@ihs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Date Foo.
Date: Fri, 20 Feb 2004 15:25:36 -0500
Message-ID: <40366D40.4030405@aol.net> (raw)
In-Reply-To: <Pine.LNX.4.33.0402191439001.7167-100000@css120.ihs.com>
References: <Pine.LNX.4.33.0402191439001.7167-100000@css120.ihs.com>

Sorry, Not looking for a way to extract a month from a timestamp. I'm 
looking for a way to convert an interval from days to months. I'm not 
sure after digging into it that there is a way to handle it in SQL, as 
the interval that results from subtracting one timestamp from another is 
not away of what months the interval spans, so there'd be no proper way 
to take month lengths into account.

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



view thread (2+ messages)  latest in thread

Message-ID: <40366D40.4030405@aol.net>
Permalink:  ../40366D40.4030405@aol.net/
Also on:    postgresql.org/message-id/40366D40.4030405@aol.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: laotse@aol.net, scott.marlowe@ihs.com
  Subject: Re: Date Foo.
  In-Reply-To: <40366D40.4030405@aol.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox