# Parse date error

**URL:** <https://discuss.elastic.co/t/parse-date-error/107962>\
**Category:** Elasticsearch\
**Created:** [November 16, 2017, 2:50pm UTC](https://discuss.elastic.co/t/parse-date-error/107962 "2017-11-16T14:50:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luc](https://avatars.discourse-cdn.com/v4/letter/l/9dc877/32.png) [@Luc](https://discuss.elastic.co/u/Luc)\
**Post date:** [November 16, 2017, 2:50pm UTC](https://discuss.elastic.co/t/parse-date-error/107962/1 "2017-11-16T14:50:02Z")

</div>

Executing the query:

```
 {
"query": {
"bool": {
  "must": [
    {
      "match": {
        "foo": "pattern"
      }
    },
    {
      "range": {
        "@timestamp": {
          "gte": "bar.start_time",
          "format": "yyyy-MM-dd'T'HH:mm:ss,SSSZ"
        }
      }
    }
  ]
}
}
}

```

I get the exception

```
   "reason": 
      "type": "parse_exception",
      "reason": "failed to parse date field [bar.start_time] with format [yyyy-MM-dd'T'HH:mm:ss,SSSZ]",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "Parse failure at index [0] of [bar.start_time]"
      }
    }

```

I really wonder how this can happen because bar.start\_time is of the format: "2017-11-16T11:35:07,821Z" and if I replace bar.start\_time with the concrete value of it, e.g. "2017-11-16T11:35:07,821Z", the query works. Anyone can help?

---

<div class="post-metadata">

**Author:** ![luiz.santos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz.santos/32/24664_2.png) [@luiz.santos](https://discuss.elastic.co/u/luiz.santos)\
**Post date:** [November 24, 2017, 6:01pm UTC](https://discuss.elastic.co/t/parse-date-error/107962/2 "2017-11-24T18:01:16Z")

</div>

Hi Luc,

In the [date range query documentation](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-range-query.html#_date_format_in_range_queries) it states that you should inform one date in the gte clause (grater than equal) and not a field name.

So, for example, if you want to find documents that have their field bar.start\_time grater than equal 2017-11-16T11:35:07,821Z:

```
GET my_index/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "bar.start_time": {
              "gte": "2015-11-16T11:35:07,821Z",
              "format": "yyyy-MM-dd'T'HH:mm:ss,SSSZ"
            }
          }
        }
      ]
    }
  }
}

```

Hope it helps!

---

<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:** [December 22, 2017, 6:01pm UTC](https://discuss.elastic.co/t/parse-date-error/107962/3 "2017-12-22T18:01:23Z")

</div>

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