# Date format not recognized

**URL:** <https://discuss.elastic.co/t/date-format-not-recognized/178401>\
**Category:** Elasticsearch\
**Created:** [April 25, 2019, 8:50am UTC](https://discuss.elastic.co/t/date-format-not-recognized/178401 "2019-04-25T08:50:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Steenbergen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter_steenbergen/32/22888_2.png) [@Peter\_Steenbergen](https://discuss.elastic.co/u/Peter_Steenbergen)\
**Post date:** [April 25, 2019, 8:50am UTC](https://discuss.elastic.co/t/date-format-not-recognized/178401/1 "2019-04-25T08:50:10Z")

</div>

Can someone help me with the following?

I have a timestamp like this, and want to create it in Elasticsearch in a datefield.  
Apr 25, 2019 12:21:19,783 AM CEST

I keep getting errors with unrecognized date format and tried many formats.  
The 783 in this case are milliseconds.

Steps that I tried with the following:

```
PUT _template/template_testindex
{
  "index_patterns": ["testindex"],
  "settings": {
    "number_of_shards": 1
    },
    "mappings" : {
      "doc" : {
         "properties" : {
          "timestamp" : {
            "type" : "date",
            "format": "MMM d, yyyy K:m:s,S a z"
          }
      }
    }
  }
}
 
PUT testindex/_doc/1
{
  "timestamp": "Apr 25, 2019 12:21:19,783 AM CEST"
}
```

---

<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 25, 2019, 2:44pm UTC](https://discuss.elastic.co/t/date-format-not-recognized/178401/2 "2019-04-25T14:44:02Z")

</div>

Hey Peter,

Try

```auto
DELETE foo

PUT foo
{
  "mappings": {
    "properties": {
      "date": {
        "type": "date",
        "format": "MMM dd, yyyy HH:mm:ss,SSS a z"
      }
    }
  }
}

PUT foo/_doc/1?refresh
{
  "date": "Apr 25, 2019 12:21:19,783 PM CEST"
}

GET foo/_search
{
  "query": {
    "range": {
      "date": {
        "gte": "2019-04-25",
        "format": "strict_date_optional_time"
      }
    }
  }
}

```

Note, I don't think your AM date in combination with `12:something` is valid.

Note 2, tested under Elasticsearch 7.0.

Hope this helps!

--Alex

---

<div class="post-metadata">

**Author:** ![Peter\_Steenbergen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter_steenbergen/32/22888_2.png) [@Peter\_Steenbergen](https://discuss.elastic.co/u/Peter_Steenbergen)\
**Post date:** [April 26, 2019, 6:40am UTC](https://discuss.elastic.co/t/date-format-not-recognized/178401/3 "2019-04-26T06:40:10Z")

</div>

Thanks Alexander. I will try this in a bit. Will try it with the real data. I created this string online with a pattern generator.

The production data will be oke I assume at this time.

---

<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 24, 2019, 6:40am UTC](https://discuss.elastic.co/t/date-format-not-recognized/178401/4 "2019-05-24T06:40:28Z")

</div>

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