# Normalizing Interval for Date Histogram

**URL:** <https://discuss.elastic.co/t/normalizing-interval-for-date-histogram/39707>\
**Category:** Elasticsearch\
**Created:** [January 20, 2016, 9:57pm UTC](https://discuss.elastic.co/t/normalizing-interval-for-date-histogram/39707 "2016-01-20T21:57:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ldum](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@ldum](https://discuss.elastic.co/u/ldum)\
**Post date:** [January 20, 2016, 9:57pm UTC](https://discuss.elastic.co/t/normalizing-interval-for-date-histogram/39707/1 "2016-01-20T21:57:19Z")

</div>

I am trying to find a way to convert the interval of a date histogram into seconds, but despite scouring the entirety of the docs and any stackoverflow posts that could potentially be relevant, I have come up with nothing of use. I want to run functions on different fields, but the result depends on time. Is there any way (short of hard-coding it into the inline script and manually changing it when I need to change the interval) that I can convert the interval time to a normalized time unit?

---

<div class="post-metadata">

**Author:** ![msimos](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@msimos](https://discuss.elastic.co/u/msimos)\
**Post date:** [January 20, 2016, 10:36pm UTC](https://discuss.elastic.co/t/normalizing-interval-for-date-histogram/39707/2 "2016-01-20T22:36:27Z")

</div>

Hi,

Maybe I'm misunderstanding your question but the interval of the date histogram takes the following time units:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units)

So for example you could specify "60s" for 60 seconds.

---

<div class="post-metadata">

**Author:** ![ldum](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@ldum](https://discuss.elastic.co/u/ldum)\
**Post date:** [January 20, 2016, 11:10pm UTC](https://discuss.elastic.co/t/normalizing-interval-for-date-histogram/39707/3 "2016-01-20T23:10:18Z")

</div>

What I want to do is convert the time internally to seconds. Like, if I had the interval be 12h, it would become 43200s so that a bucket script could run with that. If I changed the interval to 1d or 1w, I wouldn't have to manually adjust the script to accommodate the new interval

---

<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:22pm UTC](https://discuss.elastic.co/t/normalizing-interval-for-date-histogram/39707/4 "2017-07-05T23:22:51Z")

</div>


