Date range filter using strict_date_time_no_millis format failing

Hi all, I'm porting a query of an old app we have, from ES2.0 to ES7.8, and I'm getting this error:

failed to parse date field [2020-07-23T02:59:59+0000] with format [strict_date_time_no_millis]

while running a query with this range filter:
{"range": { "activation_date":{"gte": "2016-11-09T02:00:00+0000", "lte":"2020-07-23T02:59:59+0000"}}}

the activation_date field is mapped as:

"activation_date" : {
       "type" : "date",
      "format" : "strict_date_time_no_millis"
  }

But if I change the lte part of the range to 2020-07-23T02:59:59Z the query works.

Any hint of what is the problem?

I'm using a docker image of ES7.8.

@russinholi
Try format yyyy-MM-dd'T'HH:mm:ssZ.

Thanks for you answer Vinayak_Sapre, and yes using this format works, but I'm only wondering why this happens only on lte value and not on gte.

The same happens if I use it on query string like:
((something) AND activation_date:[2016-11-09T02:00:00+0000 TO 2020-07-23T02:59:59+0000])
the same error is raised, but if I change the TO part to yyyy-MM-dd'T'HH:mm:ssZformat like:
((something) AND activation_date:[2016-11-09T02:00:00+0000 TO 2020-07-23T02:59:59Z])
it works.

So why the rage limit needs to be in yyyy-MM-dd'T'HH:mm:ssZformat?

@russinholi
ES moved to java date api in 7.0. Previous versions used Joda time. I have seen many posts with inconsistencies with format. https://www.elastic.co/guide/en/elasticsearch/reference/7.x/migrate-to-java-time.html

I will do some debugging.at some point to figure out. But I don't know exact reason.

see Date parsing error in Elasticsearch 7.1

1 Like

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