Re: Interval to months

Поиск
Список
Период
Сортировка
От Aram Fingal
Тема Re: Interval to months
Дата
Msg-id 5BF7AB66-09A1-4248-852F-6F448D75D1A2@multifactorial.com
обсуждение исходный текст
Ответ на Re: Interval to months  (Steve Atkins <steve@blighty.com>)
Список 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 по дате отправления:

Предыдущее
От: David Greco
Дата:
Сообщение: Re: Set Returning Functions and joins
Следующее
От: David Johnston
Дата:
Сообщение: Re: Set Returning Functions and joins