How to split timestamps values by 24h slices ?

Поиск
Список
Период
Сортировка
От Bruno Baguette
Тема How to split timestamps values by 24h slices ?
Дата
Msg-id 49D00D27.2030409@gmail.com
обсуждение исходный текст
Ответы Re: How to split timestamps values by 24h slices ?  (Osvaldo Kussama <osvaldo.kussama@gmail.com>)
Re: How to split timestamps values by 24h slices ?  (Artacus <artacus@comcast.net>)
Список pgsql-general
Hello !

I have a table that contains two timestamps (and some other fields that
does not matter here).

the_table
----------
pk_planning_id  ==> INT8 (primary key)
timestamp_start ==> (not null timestamp without time zone)
timestamp_stop  =+> (not null timestamp without time zone)


I would like to do a SELECT of that table, but by splitting by 24h day :

So, if I have one planning from 2009-03-30 14h50 to 2009-04-01 19h00, I
would like to get three lines in my SELECT result :

123 | 2009-03-30 14h50 | 2009-03-30 24h00
123 | 2009-03-31 00h00 | 2009-03-31 24h00
123 | 2009-04-01 00h00 | 2009-04-01 19h00

I was thinking of doing that by playing with three UNION requests
(beginning date, intermediate(s) date(s) and ending dates.

Am i going in the right way or is there a cleanest (or more elegant) way
to do that ?

Thanks in advance !

Regards,

--
Bruno Baguette


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

Предыдущее
От: "V S P"
Дата:
Сообщение: [Q] rollback after select?
Следующее
От: "V S P"
Дата:
Сообщение: Re: [Q] rollback after select?