Re: Aggregate time data on half hour interval

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Aggregate time data on half hour interval
Дата
Msg-id 23506.964070451@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Aggregate time data on half hour interval  (Lars <lars@sscsinc.com>)
Ответы Re: Aggregate time data on half hour interval  (Lars <lars@sscsinc.com>)
Re: Aggregate time data on half hour interval  (Kyle <kaf@nwlink.com>)
Список pgsql-general
Lars <lars@sscsinc.com> writes:
> What I would like to do though is aggregate by each half hour or maybe
> even 20 minutes. Does anyone know a good way to do this?

I don't have a *good* answer, but a brute-force way is

* convert timestamp to integer seconds with date_part('epoch', foo)
* round to a multiple of desired time interval
* convert back to timestamp for display via timestamp()

In the long run it seems like date_trunc ought to be more flexible
than it is...

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Chris Bitmead
Дата:
Сообщение: Re: [HACKERS] Re: PRIMARY KEY & INHERITANCE (fwd)
Следующее
От: Thomas Lockhart
Дата:
Сообщение: Re: Aggregate time data on half hour interval