Re: Interval to months - Mailing list pgsql-general

From Aram Fingal
Subject Re: Interval to months
Date
Msg-id 5BF7AB66-09A1-4248-852F-6F448D75D1A2@multifactorial.com
Whole thread Raw
In response to Re: Interval to months  (Steve Atkins <steve@blighty.com>)
List pgsql-general
On Aug 7, 2012, at 11:55 AM, Steve Atkins wrote:

Something like this?

select 12 * extract(year from ?) + extract(month from ?) + extract(epoch from ? - date_trunc('month', ?)) / 2592000

Ugly, but likely closer to accurate. You can't get actually accurate, of course, as you don't know how long a month is.

Thanks very much.  I checked several examples of short, medium and long intervals (in the context of my data set) and your solution returns all of them exactly as they were in the text files which I used to import the data.  That's as much accuracy as I need.  I don't even know the exact standard used by the source for a month, though I could ask if it becomes an issue.   

-Aram Fingal

pgsql-general by date:

Previous
From: David Greco
Date:
Subject: Re: Set Returning Functions and joins
Next
From: David Johnston
Date:
Subject: Re: Set Returning Functions and joins