# Indexing Date Ranges

**URL:** <https://discuss.elastic.co/t/indexing-date-ranges/36524>\
**Category:** Elasticsearch\
**Created:** [December 7, 2015, 11:41am UTC](https://discuss.elastic.co/t/indexing-date-ranges/36524 "2015-12-07T11:41:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsimon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rsimon/32/5977_2.png) [@rsimon](https://discuss.elastic.co/u/rsimon)\
**Post date:** [December 7, 2015, 11:41am UTC](https://discuss.elastic.co/t/indexing-date-ranges/36524/1 "2015-12-07T11:41:13Z")

</div>

I need to index objects that have a date range associated with them (date from/to), rather than just a single date. At query time, retrieving objects that intersect a certain interval is pretty straightforward. But what I can't work out is a way to generate date histograms for my data, along the lines of the [standard date histogram aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/1.5/search-aggregations-bucket-datehistogram-aggregation.html) that works on single date fields. Any thoughts?

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [December 7, 2015, 11:45am UTC](https://discuss.elastic.co/t/indexing-date-ranges/36524/2 "2015-12-07T11:45:22Z")

</div>

Maybe the following topic would be useful to you? It uses a start date and a duration but the approach could easily be modified to use a start and end date instead.

> [@Display concurrency in data on Kibana](https://discuss.elastic.co/t/display-concurrency-in-data-on-kibana/26006/3):
>
> You can actually do this if you query Elasticsearch directly by using a script on a date\_histogram aggregation which adds the call document to all the buckets from the start\_time to start\_time + duration. The following gist contains a Sense recreation that details what I mean: [https://gist.github.com/jpountz/cebb8452648c36099cee](https://gist.github.com/jpountz/cebb8452648c36099cee) As for doing this in Kibana, I know it's possible to run scripts in Kibana for some actions but I'm not sure if this would be possible, maybe someone more familiar with…

---

<div class="post-metadata">

**Author:** ![rsimon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rsimon/32/5977_2.png) [@rsimon](https://discuss.elastic.co/u/rsimon)\
**Post date:** [December 7, 2015, 12:12pm UTC](https://discuss.elastic.co/t/indexing-date-ranges/36524/3 "2015-12-07T12:12:35Z")

</div>

Excellent - yes that looks exactly like what I was looking for (and will help me wrap my head around scripting too 🙂 )

Many thanks for the quick answer!

---

<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:** [July 5, 2017, 11:33pm UTC](https://discuss.elastic.co/t/indexing-date-ranges/36524/4 "2017-07-05T23:33:02Z")

</div>


