# Date math and rounding is not work when the format is not specified

**URL:** <https://discuss.elastic.co/t/date-math-and-rounding-is-not-work-when-the-format-is-not-specified/176993>\
**Category:** Elasticsearch\
**Created:** [April 16, 2019, 4:33am UTC](https://discuss.elastic.co/t/date-math-and-rounding-is-not-work-when-the-format-is-not-specified/176993 "2019-04-16T04:33:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeffreyQ](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeffreyq/32/44210_2.png) [@JeffreyQ](https://discuss.elastic.co/u/JeffreyQ)\
**Post date:** [April 16, 2019, 4:33am UTC](https://discuss.elastic.co/t/date-math-and-rounding-is-not-work-when-the-format-is-not-specified/176993/1 "2019-04-16T04:33:19Z")

</div>

We use ES 2.4.1.  
When the date datatype field does not specify the 'format', we use the rounded date and specify the format in the query, the query result is incorrect.

```auto
mapping:
{
    "rd": {
              "type": "date",
              "format": "strict_date_optional_time||epoch_millis"
           },
}

query:
{
    "range" : {
      "rd" : {
        "from" : "2012-11-11||/M",
        "to" : "2013-01-11||/M",
        "format" : "yyyy-MM-dd",
        "include_lower" : true,
        "include_upper" : true
      }
    }
}

result:
{
  "hits": {
      "total": 0,
      "max_score": null,
      "hits": []
   }
}

```

When the 'format' is specified, the query result is correct.

```auto
{
    "rd": {
              "type": "date",
              "format": "yyyyMMdd||strict_date_optional_time||epoch_millis"
           },
}

```

Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 16, 2019, 4:32pm UTC](https://discuss.elastic.co/t/date-math-and-rounding-is-not-work-when-the-format-is-not-specified/176993/2 "2019-04-16T16:32:32Z")

</div>

Hey,

I'm sorry, but that Elasticsearch version has not been supported for quite some years, and we will not provide any bugfixes for that version. Please use a recent version (like 7.0) and provide an example that can be fully reproduced by copy/pasting, so we can see if your issue still exists.

Thanks!

--Alex

---

<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:** [May 14, 2019, 4:32pm UTC](https://discuss.elastic.co/t/date-math-and-rounding-is-not-work-when-the-format-is-not-specified/176993/3 "2019-05-14T16:32:33Z")

</div>

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