From: | Aram Fingal <fingal(at)multifactorial(dot)com> |
---|---|
To: | Postgres-General General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Interval to months |
Date: | 2012-08-15 20:50:24 |
Message-ID: | 5BF7AB66-09A1-4248-852F-6F448D75D1A2@multifactorial.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | David Johnston | 2012-08-15 20:57:07 | Re: Set Returning Functions and joins |
Previous Message | David Greco | 2012-08-15 20:24:43 | Re: Set Returning Functions and joins |