# Malformed date value? But the date and the template match

**URL:** https://discuss.elastic.co/t/malformed-date-value-but-the-date-and-the-template-match/39488
**Category:** Elasticsearch
**Created:** [January 18, 2016, 10:27pm UTC](https://discuss.elastic.co/t/malformed-date-value-but-the-date-and-the-template-match/39488 "2016-01-18T22:27:43Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Christopher\_Curzon](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@Christopher\_Curzon](https://discuss.elastic.co/u/Christopher_Curzon)
#### Post date: [January 18, 2016, 10:27pm UTC](https://discuss.elastic.co/t/malformed-date-value-but-the-date-and-the-template-match/39488/1 "2016-01-18T22:27:43Z")

</div>

CSV data looks like his

220364000,2015-09-04 11:04:23,Under way using engine,65.5000000,-53.5114983

Mapping to create index a009 was created this way.

$ curl -XPUT '[http://10.30.90.5:9200/a009](http://10.30.90.5:9200/a009)' -d '{  
"mappings": {  
"type": {  
"properties": {  
"mmsi" : { "type": "string" },  
"datetime" : { "type": "date", "format": "YYYY-MM-dd HH:mm:ss"},  
"status" : { "type": "string", "index": "not\_analyzed" },  
"lat" : { "type": "float" },  
"long" : { "type": "float" }  
}  
}  
}  
}'

Getting this error:

"error"=\>{"type"=\>"mapper\_parsing\_exception",  
"reason"=\>"failed to parse [datetime]",  
"caused\_by"=\>{"type"=\>"illegal\_argument\_exception",  
"reason"=\>"Invalid format: "2015-09-04 11:04:23" is malformed at " 11:04:23""}}

How is it that

2015-09-04 11:04:23 (a date value)

is malformed?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [January 18, 2016, 10:57pm UTC](https://discuss.elastic.co/t/malformed-date-value-but-the-date-and-the-template-match/39488/2 "2016-01-18T22:57:56Z")

</div>

I've moved this to the ES area as it's more suitable than LS 🙂

---

<div class="post-metadata">

### Author: ![Christopher\_Curzon](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@Christopher\_Curzon](https://discuss.elastic.co/u/Christopher_Curzon)
#### Post date: [January 18, 2016, 11:03pm UTC](https://discuss.elastic.co/t/malformed-date-value-but-the-date-and-the-template-match/39488/3 "2016-01-18T23:03:06Z")

</div>

OK... Thanks.

---

<div class="post-metadata">

### Author: ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)
#### Post date: [January 19, 2016, 9:42am UTC](https://discuss.elastic.co/t/malformed-date-value-but-the-date-and-the-template-match/39488/4 "2016-01-19T09:42:02Z")

</div>

I could be wrong but I think you have to wrap literal characters in `'`'s so your format in your mapping should be:

```auto
 "format": "YYYY-MM-dd' 'HH:mm:ss"

```

see [https://www.elastic.co/guide/en/elasticsearch/reference/2.1/mapping-date-format.html#custom-date-formats](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/mapping-date-format.html#custom-date-formats) and [http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html](http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html) for more details on the date format

---

<div class="post-metadata">

### Author: ![sandros](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandros/32/6348_2.png) [@sandros](https://discuss.elastic.co/u/sandros)
#### Post date: [January 19, 2016, 4:11pm UTC](https://discuss.elastic.co/t/malformed-date-value-but-the-date-and-the-template-match/39488/5 "2016-01-19T16:11:25Z")

</div>

This works for me in ES2.0, only diff I see is yyyy vs YYYY

```
"post_date_gmt": {
                "type": "date",
                "format": "yyyy-MM-dd HH:mm:ss"
            },
```

---

<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, 11:23pm UTC](https://discuss.elastic.co/t/malformed-date-value-but-the-date-and-the-template-match/39488/6 "2017-07-05T23:23:23Z")

</div>


