# How to build date\_range agg when date field has default format but the value is stored as seconds?

**URL:** <https://discuss.elastic.co/t/how-to-build-date-range-agg-when-date-field-has-default-format-but-the-value-is-stored-as-seconds/113907>\
**Category:** Elasticsearch\
**Created:** [January 3, 2018, 10:54am UTC](https://discuss.elastic.co/t/how-to-build-date-range-agg-when-date-field-has-default-format-but-the-value-is-stored-as-seconds/113907 "2018-01-03T10:54:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Athar.Khan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/athar.khan/32/11951_2.png) [@Athar.Khan](https://discuss.elastic.co/u/Athar.Khan)\
**Post date:** [January 3, 2018, 10:54am UTC](https://discuss.elastic.co/t/how-to-build-date-range-agg-when-date-field-has-default-format-but-the-value-is-stored-as-seconds/113907/1 "2018-01-03T10:54:41Z")

</div>

Hi,

ES v5.3.

I've a date field "created" with default format strict\_date\_optional\_time||epoch\_millis. But the values are stored in seconds. I need to build date\_range aggregation query but I don't get any result. I've tried, yyyy-MM-dd, seconds and milliseconds but no luck. I am sure this happening because of the wrong value store in the date field. It should have been either millisec or yyyy-MM-dd. Is it possible to get the query working without reindexing field with milliseconds?

Thanks

---

<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:** [January 31, 2018, 11:06am UTC](https://discuss.elastic.co/t/how-to-build-date-range-agg-when-date-field-has-default-format-but-the-value-is-stored-as-seconds/113907/2 "2018-01-31T11:06:11Z")

</div>

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