# Filter query URI in elasticsearch based on dates

**URL:** https://discuss.elastic.co/t/filter-query-uri-in-elasticsearch-based-on-dates/196053
**Category:** Elasticsearch
**Created:** [August 21, 2019, 7:23am UTC](https://discuss.elastic.co/t/filter-query-uri-in-elasticsearch-based-on-dates/196053 "2019-08-21T07:23:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Anshuman\_Kirty](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Anshuman\_Kirty](https://discuss.elastic.co/u/Anshuman_Kirty)
#### Post date: [August 21, 2019, 7:23am UTC](https://discuss.elastic.co/t/filter-query-uri-in-elasticsearch-based-on-dates/196053/1 "2019-08-21T07:23:08Z")

</div>

Not able to filter the elasticsearch data based on dates. Not able to correctly figure out the syntax.  
Have tried all below given queries.

```auto
localhost:9200/index/_search?q=date:>=2019-01-01  
localhost:9200/index/_search?q=date:>=2019-01-01 00:00:00.0
localhost:9200/index/_search?q=date:>=2019-01-01T00:00:00.0

```

Need to fetch all the docs that have date \> 2019-01-01 00:00:00.

Error: "type":"parse\_exception","reason":"failed to parse date field [2019-01-01] with format [yyyy-MM-dd HH:mm:ss.S]"}]

---

<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: [August 22, 2019, 12:34pm UTC](https://discuss.elastic.co/t/filter-query-uri-in-elasticsearch-based-on-dates/196053/2 "2019-08-22T12:34:19Z")

</div>

hey,

assumption here. The `date_format` configured in the mapping for the `date` field is `yyyy-MM-dd HH:mm:ss.S` and therefore Elasticsearch expects the date field in the query to resemble that format.

A possible alternative here wold be to use a [date range query](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl-range-query.html) with a customized format.

--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: [September 19, 2019, 12:34pm UTC](https://discuss.elastic.co/t/filter-query-uri-in-elasticsearch-based-on-dates/196053/3 "2019-09-19T12:34:26Z")

</div>

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