# Date Time Issue with Index

**URL:** <https://discuss.elastic.co/t/date-time-issue-with-index/231391>\
**Category:** Elasticsearch\
**Created:** [May 6, 2020, 6:48pm UTC](https://discuss.elastic.co/t/date-time-issue-with-index/231391 "2020-05-06T18:48:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![adwaitjoshi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adwaitjoshi/32/35098_2.png) [@adwaitjoshi](https://discuss.elastic.co/u/adwaitjoshi)\
**Post date:** [May 6, 2020, 6:48pm UTC](https://discuss.elastic.co/t/date-time-issue-with-index/231391/1 "2020-05-06T18:48:51Z")

</div>

when I apply a date filter, I get this error, my data is correct (when checked from individual index)

```auto
Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"parse_exception","reason":"failed to parse date field [11/01/2019] with format [strict_date_optional_time||epoch_millis]: [failed to parse date field [11/01/2019] with format [strict_date_optional_time||epoch_millis]]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"masterdata_sutton","node":"GmJc3-wgQPe3-BzzbdkccQ","reason":{"type":"parse_exception","reason":"failed to parse date field [11/01/2019] with format [strict_date_optional_time||epoch_millis]: [failed to parse date field [11/01/2019] with format [strict_date_optional_time||epoch_millis]]","caused_by":{"type":"illegal_argument_exception","reason":"failed to parse date field [11/01/2019] with format [strict_date_optional_time||epoch_millis]","caused_by":{"type":"date_time_parse_exception","reason":"date_time_parse_exception: Failed to parse with all enclosed parsers"}}}}]},"status":400}

```

---

<div class="post-metadata">

**Author:** ![marrel](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@marrel](https://discuss.elastic.co/u/marrel)\
**Post date:** [May 14, 2020, 2:05pm UTC](https://discuss.elastic.co/t/date-time-issue-with-index/231391/2 "2020-05-14T14:05:34Z")

</div>

I am facing the same problem.  
Any advice will be greatly appreciated! thank you!

---

<div class="post-metadata">

**Author:** ![adwaitjoshi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adwaitjoshi/32/35098_2.png) [@adwaitjoshi](https://discuss.elastic.co/u/adwaitjoshi)\
**Post date:** [May 14, 2020, 8:40pm UTC](https://discuss.elastic.co/t/date-time-issue-with-index/231391/3 "2020-05-14T20:40:05Z")

</div>

I have set explicit dates formats in my template now

---

<div class="post-metadata">

**Author:** ![marrel](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@marrel](https://discuss.elastic.co/u/marrel)\
**Post date:** [May 15, 2020, 7:54am UTC](https://discuss.elastic.co/t/date-time-issue-with-index/231391/4 "2020-05-15T07:54:12Z")

</div>

Today I also found the solution @adwaitjoshi. For my case, I do not use date format in the index mapping, I just use the same format date that the `TIMESTAMP` field has in the doc. And it's working.

---

<div class="post-metadata">

**Author:** ![adwaitjoshi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adwaitjoshi/32/35098_2.png) [@adwaitjoshi](https://discuss.elastic.co/u/adwaitjoshi)\
**Post date:** [May 15, 2020, 11:38am UTC](https://discuss.elastic.co/t/date-time-issue-with-index/231391/5 "2020-05-15T11:38:22Z")

</div>

What was your fix? Put it for the rest of the world here please.

---

<div class="post-metadata">

**Author:** ![marrel](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@marrel](https://discuss.elastic.co/u/marrel)\
**Post date:** [May 18, 2020, 2:01pm UTC](https://discuss.elastic.co/t/date-time-issue-with-index/231391/6 "2020-05-18T14:01:24Z")

</div>

Please check the below two solutions that are working for me:  
**1st way**

```
GET your_index/_search
{
  "query":{
    "range":{
      "your_time_field":{
        "gte": "2019-01-01T00:00:00.000+0200",
        "lte": "2019-06-30T23:59:59.000+0200"
      }
    }
  }
}

```

Here the format of the field `your_time_field` `"2019-01-01T00:00:00.000+0400"` is exactly as it is included in my relevant field of the index.

**2nd way**

```
GET your_index/_search
{
  "query":{
    "range":{
      "your_time_field":{
        "gte": "01-01-2019",
        "lte": "30-06-2019",
        "format": "dd-MM-yyyy"
      }
    }
  }
}

```

Here you can include an extra line `"format"` and write the time range of `"gte"` and `"lte"` according to the time format you prefer (mine is as aforementioned above `"format": "dd-MM-yyyy"`). This API will return the results with your `"your_time_field"` format as you have stated regardless of how the time format has been registered in the index.

---

<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:** [June 15, 2020, 2:01pm UTC](https://discuss.elastic.co/t/date-time-issue-with-index/231391/7 "2020-06-15T14:01:30Z")

</div>

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