# Calculate a list of identical date prefixes for a date range

**URL:** <https://discuss.elastic.co/t/calculate-a-list-of-identical-date-prefixes-for-a-date-range/277199>\
**Category:** Elasticsearch\
**Created:** [June 28, 2021, 10:11am UTC](https://discuss.elastic.co/t/calculate-a-list-of-identical-date-prefixes-for-a-date-range/277199 "2021-06-28T10:11:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asasas234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asasas234/32/113152_2.png) [@asasas234](https://discuss.elastic.co/u/asasas234)\
**Post date:** [June 28, 2021, 10:11am UTC](https://discuss.elastic.co/t/calculate-a-list-of-identical-date-prefixes-for-a-date-range/277199/1 "2021-06-28T10:11:06Z")

</div>

The background is, I want to use the keyword field to optimize the search of 1 date range, because it is keyword, I need to use prefix search, but if it is 1 date range, I need to calculate 2 date prefixes based on the start date and end date, and I want to be able to output only 2021-06 instead of every day in, for example, a cross-month scenario, which can greatly help me to streamline the parameters, but to calculate this thing is too much trouble, please ask what tool class can do this?

---

<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 26, 2021, 10:11am UTC](https://discuss.elastic.co/t/calculate-a-list-of-identical-date-prefixes-for-a-date-range/277199/2 "2021-07-26T10:11:50Z")

</div>

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