# Invalid format for date

**URL:** https://discuss.elastic.co/t/invalid-format-for-date/56375
**Category:** Elasticsearch
**Created:** [July 26, 2016, 9:48am UTC](https://discuss.elastic.co/t/invalid-format-for-date/56375 "2016-07-26T09:48:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![shivkumar](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@shivkumar](https://discuss.elastic.co/u/shivkumar)
#### Post date: [July 26, 2016, 9:48am UTC](https://discuss.elastic.co/t/invalid-format-for-date/56375/1 "2016-07-26T09:48:15Z")

</div>

Hello ,

I am trying to use Index Template. The following is my template

```
 {
        "template": "te*",
        "settings": {
            "number_of_shards": 1
        },
        "mappings": {
            "log": {
                "properties": {
                    "@timestamp": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss.SSSZ",
                        "index": "not_analyzed"
                    },
                    "log_generation_date": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss.SSSZ",
                        "index": "not_analyzed"
                    }
                }
            }
        }
    }

```

After this I have created my index and then I am trying to insert a document using the following command:

```
curl -XPUT 'localhost:9200/templateindex/demo/1?pretty' -d '
{
             
            
                   "@timestamp" : "2016-07-26T05:42:27.781Z", 
                 "log_generation_date" : "2014-02-06T00:00:38.000Z"

}'

```

I am getting the following error:

```
{
  "error" : {
    "root_cause" : [ {
      "type" : "mapper_parsing_exception",
      "reason" : "failed to parse [@timestamp]"
    } ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse [@timestamp]",
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "Invalid format: \"2016-07-26T05:42:27.781Z\" is malformed at \"T05:42:27.781Z\""
    }
  },
  "status" : 400
}

```

What I am doing wrong here ?  
I hope my format is correct.

Thank you

---

<div class="post-metadata">

### Author: ![shivkumar](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@shivkumar](https://discuss.elastic.co/u/shivkumar)
#### Post date: [July 26, 2016, 11:11am UTC](https://discuss.elastic.co/t/invalid-format-for-date/56375/2 "2016-07-26T11:11:19Z")

</div>

Done.

I removed the 'format' and it is working

---

<div class="post-metadata">

### Author: ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)
#### Post date: [July 27, 2016, 7:15pm UTC](https://discuss.elastic.co/t/invalid-format-for-date/56375/3 "2016-07-27T19:15:35Z")

</div>

Hello shivkumar,

Just to give you small feedback. Your format was wrong, it specifying a space instead of "T".

It worked when you removed because that timestamp you are using is actually a standard format that elasticsearch already understands.

Cheers

---

<div class="post-metadata">

### Author: ![shivkumar](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@shivkumar](https://discuss.elastic.co/u/shivkumar)
#### Post date: [August 3, 2016, 5:27pm UTC](https://discuss.elastic.co/t/invalid-format-for-date/56375/4 "2016-08-03T17:27:29Z")

</div>

Thank you sir for your feed back:slight\_smile:

---

<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: [July 5, 2017, 10:30pm UTC](https://discuss.elastic.co/t/invalid-format-for-date/56375/5 "2017-07-05T22:30:21Z")

</div>


