Split daterange into sub periods

Поиск
Список
Период
Сортировка
От hmidi slim
Тема Split daterange into sub periods
Дата
Msg-id CAMsqVxsSiN_-Tx3tPzAammUyQNBVOKY3cpHfdGFb8wVX7oK3+w@mail.gmail.com
обсуждение исходный текст
Ответы Re: Split daterange into sub periods  (Adrian Klaver <adrian.klaver@aklaver.com>)
Split daterange into sub periods  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Split daterange into sub periods  (Andreas Kretschmer <andreas@a-kretschmer.de>)
Список pgsql-general
Hi,
I'm looking for splitting a daterange into many subperiods following this example:

Base Date: [2018-01-01, 2018-01-31]
overlapped_periods:
1- [ 2018-01-04, 2018-01-06]
2- [ 2018-01-09, 2018-01-12]
3- [ 2018-01-18, 2018-01-19]

I try to get such a result:
1- [ 2018-01-01, 2018-01-03]
2- [ 2018-01-07, 2018-01-08]
3- [ 2018-01-13, 2018-01-17]
4- [ 2018-01-20, 2018-01-31]

The operator '-' does not support this :
SELECT daterange('2018-01-01', '2018-01-31', '[]') - daterange('2018-01-04', '2018-01-06', '[]');

I got this error:
ERROR: result of range difference would not be contiguous

Is there any operators to make the split of daterange?





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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: FK v.s unique indexes
Следующее
От: Melvin Davidson
Дата:
Сообщение: Re: Cloning schemas