Re: Split daterange into sub periods

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Re: Split daterange into sub periods
Дата
Msg-id CA+bJJbxQ6XRJzOs9Be1G+TAu5fAKC7zd8ZotvegZKiGMC0D9ZA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Split daterange into sub periods  (hmidi slim <hmidi.slim2@gmail.com>)
Список pgsql-general
On Thu, Jul 5, 2018 at 4:16 PM, hmidi slim <hmidi.slim2@gmail.com> wrote:
> In fact I'm trying to split a period in sub periods. Following this example
> :
> If I have a period =[2018-01-01, 2018-01-31] and two other periods
> [2018-01-04, 2018-01-06] and [2018-01-08, 2018-01-08].
> If I split the base period '[2018-01-01, 2018-01-31]' by the other two
> periods '[2018-01-04, 2018-01-06]' and '[2018-01-08, 2018-01-08]' I will got
> such a result:
> [2018-01-01, 2018-01-03]
> [2018-01-07, 2018-01-07]
> [2018-01-09, 2018-01-31].

Your example maybe fine to illustrate a definition, but it is totally
inadequate to describe what you want.

You'll, at least, need to refine your question. Something like "I have
a big period and a set of small periods, and want to calculate the set
of subperiods of the big one not covered by the small ones", and also
some conditions ( i.e., can the small periods interesect? are they
completely covered by the big one? can they include the endpoints of
the big one? Can they be empty? Does the result need to be minimal (
in the number of result periods ) ? ).

Even then, this is not trivial and, as said above, you will probably
need a function for it.


Francisco Olarte.


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

Предыдущее
От: hmidi slim
Дата:
Сообщение: Re: Split daterange into sub periods
Следующее
От: Łukasz Jarych
Дата:
Сообщение: Re: Cloning schemas