Search Postgresql Archives

Re: Interval to months

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux