# Date histogram 6 months interval

**URL:** <https://discuss.elastic.co/t/date-histogram-6-months-interval/278526>\
**Category:** Kibana\
**Created:** [July 13, 2021, 11:11am UTC](https://discuss.elastic.co/t/date-histogram-6-months-interval/278526 "2021-07-13T11:11:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![paigekim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paigekim/32/91494_2.png) [@paigekim](https://discuss.elastic.co/u/paigekim)\
**Post date:** [July 13, 2021, 11:11am UTC](https://discuss.elastic.co/t/date-histogram-6-months-interval/278526/1 "2021-07-13T11:11:27Z")

</div>

Hello,

I just wonder whether I can draw the vertical bar with 6 months interval. I see that it supports other units but I cannot find an example of having half a year interval.

Thank you!

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/1/315d68b367cbdf2e622e33d22fa41ecca38339d2.png)

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [July 13, 2021, 2:26pm UTC](https://discuss.elastic.co/t/date-histogram-6-months-interval/278526/2 "2021-07-13T14:26:23Z")

</div>

You can type into the "Minimum interval" input the value `6M` which is 6 months. `quarter` is not a valid date unit.

---

<div class="post-metadata">

**Author:** ![paigekim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paigekim/32/91494_2.png) [@paigekim](https://discuss.elastic.co/u/paigekim)\
**Post date:** [July 13, 2021, 11:36pm UTC](https://discuss.elastic.co/t/date-histogram-6-months-interval/278526/3 "2021-07-13T23:36:42Z")

</div>

First of all, thank you for your reply!

I saw that quarter unit from this link. [Date histogram aggregation | Elasticsearch Guide [7.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.12/search-aggregations-bucket-datehistogram-aggregation.html)  
Have I understand incorrectly? because the values come out with quarter interval as I expected.

And, minimum interval you suggested gives me an error as below...

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/1/d10588e360232f223f5f45ad298522b734152a56.png)

---

<div class="post-metadata">

**Author:** ![paigekim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paigekim/32/91494_2.png) [@paigekim](https://discuss.elastic.co/u/paigekim)\
**Post date:** [July 13, 2021, 11:45pm UTC](https://discuss.elastic.co/t/date-histogram-6-months-interval/278526/4 "2021-07-13T23:45:48Z")

</div>

If I use '183d'(which is round up days for 6 months period) as minimum interval, it works but I think minimum interval starts from the date of first value.

Would you possible to provide another suggestion that I can have interval from January to June and July to December regardless the values?

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [July 14, 2021, 12:14pm UTC](https://discuss.elastic.co/t/date-histogram-6-months-interval/278526/5 "2021-07-14T12:14:00Z")

</div>

"Minimum" in this context refers to the fact that Kibana will scale up the interval if there would be too many buckets otherwise (by default more than 200). For your use case it doesn't seem relevant.

I believe the problem you hit with using `6M` is alrareadz reported in this issue: [Date histogram minimum interval cannot be multiple of weeks · Issue #97162 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/97162)

---

<div class="post-metadata">

**Author:** ![paigekim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paigekim/32/91494_2.png) [@paigekim](https://discuss.elastic.co/u/paigekim)\
**Post date:** [July 14, 2021, 1:20pm UTC](https://discuss.elastic.co/t/date-histogram-6-months-interval/278526/6 "2021-07-14T13:20:53Z")

</div>

Thank you for your reply.

So if that is the case, is it correct that I cannot set the interval as 6 months(Jan-June, July-Dec) at the moment?

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [July 14, 2021, 2:34pm UTC](https://discuss.elastic.co/t/date-histogram-6-months-interval/278526/7 "2021-07-14T14:34:02Z")

</div>

I stand corrected that `quarter` and `1q` are valid calendar intervals, but you can't do `2q` or `6M` because the calendar intervals can't be multiplied.

As a workaround, here are your options:

- Use the `Filters` or `Date Range` aggregation to manually create the 6 month intervals. For example, `date >= 2021-01-01 AND date < 2021-07-01`
- Create a runtime or scripted field using Painless scripting to manually determine which half of the year you're in, for example if the date is in July you could return `2H` as your scripted date. See the docs here for examples: [Using Datetime in Painless | Painless Scripting Language [7.13] | Elastic](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-datetime.html)

---

<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:** [August 11, 2021, 2:34pm UTC](https://discuss.elastic.co/t/date-histogram-6-months-interval/278526/8 "2021-08-11T14:34:25Z")

</div>

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