# Query to show gaps between multiple date ranges

**URL:** <https://discuss.elastic.co/t/query-to-show-gaps-between-multiple-date-ranges/155352>\
**Category:** Elasticsearch\
**Created:** [November 5, 2018, 7:42am UTC](https://discuss.elastic.co/t/query-to-show-gaps-between-multiple-date-ranges/155352 "2018-11-05T07:42:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tony-dillon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tony-dillon/32/34762_2.png) [@tony-dillon](https://discuss.elastic.co/u/tony-dillon)\
**Post date:** [November 5, 2018, 7:42am UTC](https://discuss.elastic.co/t/query-to-show-gaps-between-multiple-date-ranges/155352/1 "2018-11-05T07:42:33Z")

</div>

We have a nested field which is used to store date ranges that represent the occupancy of rooms.

Is there any way to formulate a query which can identify `gaps` in room occupancy?

The concrete example is that we would like to be able to find all the periods when the room is available for booking.

Many thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 3, 2018, 7:42am UTC](https://discuss.elastic.co/t/query-to-show-gaps-between-multiple-date-ranges/155352/2 "2018-12-03T07:42:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
