# Date Invalid format too short

**URL:** https://discuss.elastic.co/t/date-invalid-format-too-short/141046
**Category:** Elasticsearch
**Created:** [July 22, 2018, 7:27pm UTC](https://discuss.elastic.co/t/date-invalid-format-too-short/141046 "2018-07-22T19:27:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![magedmakled](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magedmakled/32/69937_2.png) [@magedmakled](https://discuss.elastic.co/u/magedmakled)
#### Post date: [July 22, 2018, 7:27pm UTC](https://discuss.elastic.co/t/date-invalid-format-too-short/141046/1 "2018-07-22T19:27:58Z")

</div>

I have an elasticsearch model with a field `starts_at` with the mapping

```
"starts_at": {
               "type": "date",
               "format": "yyyy-MM-dd'T'HH:mm:ssZ"
             }

```

When I try to enter `2018-07-29T13:00:00Z`, I get the error `Invalid format: \"2018-07-29\" is too short"`

```
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse [starts_at]"}],"type":"mapper_parsing_exception","reason":"failed to parse [starts_at]","caused_by":{"type":"illegal_argument_exception","reason":"Invalid format: \"2018-07-29\" is too short"}},"status":400}

```

What Am I doing wrong?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 22, 2018, 7:46pm UTC](https://discuss.elastic.co/t/date-invalid-format-too-short/141046/2 "2018-07-22T19:46:54Z")

</div>

Just wondering about `2018-07-29T13:00:00Z`. What is the meaning of `Z` here?  
It should be a time zone I think.

---

<div class="post-metadata">

### Author: ![magedmakled](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magedmakled/32/69937_2.png) [@magedmakled](https://discuss.elastic.co/u/magedmakled)
#### Post date: [July 22, 2018, 7:58pm UTC](https://discuss.elastic.co/t/date-invalid-format-too-short/141046/3 "2018-07-22T19:58:33Z")

</div>

so the format with the `Z` is a `UTC` format but I also get the same error if I try to enter `2018-07-29T08:00:00-05:00`

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 22, 2018, 8:22pm UTC](https://discuss.elastic.co/t/date-invalid-format-too-short/141046/4 "2018-07-22T20:22:28Z")

</div>

This works well on my end:

```auto
DELETE test 
PUT test
{
  "mappings": {
    "_doc": {
      "properties": {
        "starts_at": {
          "type": "date",
          "format": "yyyy-MM-dd'T'HH:mm:ssZ"
        }
      }
    }
  }
}
POST test/_doc
{
  "starts_at": "2018-07-29T08:00:00-05:00"
}

```

---

<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: [August 19, 2018, 8:22pm UTC](https://discuss.elastic.co/t/date-invalid-format-too-short/141046/5 "2018-08-19T20:22:31Z")

</div>

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