# How to show year only in X-axis, Kibana using date histogram?

**URL:** <https://discuss.elastic.co/t/how-to-show-year-only-in-x-axis-kibana-using-date-histogram/254649>\
**Category:** Kibana\
**Created:** [November 8, 2020, 5:58am UTC](https://discuss.elastic.co/t/how-to-show-year-only-in-x-axis-kibana-using-date-histogram/254649 "2020-11-08T05:58:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Storm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_storm/32/68503_2.png) [@Mike\_Storm](https://discuss.elastic.co/u/Mike_Storm)\
**Post date:** [November 8, 2020, 5:58am UTC](https://discuss.elastic.co/t/how-to-show-year-only-in-x-axis-kibana-using-date-histogram/254649/1 "2020-11-08T05:58:34Z")

</div>

how can I display the year only on a date histogram, I would like to display the years, but it seems i have intervals,

please see below screenshot

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

however I tried Terms aggregation here's the result, I want to achieve the first screenshot to diplay the year only but It should display all the years from 1990 - 2019.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/a/9ab397879bd2b759264fe7642b315869ec7b6f96.png)

thank you in advance

best regards

---

<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:** [November 9, 2020, 2:20pm UTC](https://discuss.elastic.co/t/how-to-show-year-only-in-x-axis-kibana-using-date-histogram/254649/2 "2020-11-09T14:20:50Z")

</div>

The visualization tries to be smart and limits the amount of ticks displayed for dates - in this case it's only showing only every second label.

To work around this, try to create a scripted field for the year (as a number, not a date) and use the terms aggregation on that: `doc['year'].value.getYear()`

---

<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 7, 2020, 2:20pm UTC](https://discuss.elastic.co/t/how-to-show-year-only-in-x-axis-kibana-using-date-histogram/254649/3 "2020-12-07T14:20:51Z")

</div>

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