# Date Issue - Invalid format … malformed

**URL:** https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391
**Category:** Elasticsearch
**Created:** [April 26, 2016, 7:40am UTC](https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391 "2016-04-26T07:40:59Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![muhamadli302](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@muhamadli302](https://discuss.elastic.co/u/muhamadli302)
#### Post date: [April 26, 2016, 7:40am UTC](https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391/1 "2016-04-26T07:40:59Z")

</div>

Hi everyone,

I've created a template index, looks something like that:

```
{
    "template" : "te*",
    "mappings" : {
        "msg" : {
            "date : { "type" : "date, "format" : "date_optional_time"}
            "contetnt":{"type" : "string", "index" : "not-analyzed"}
        }
    }
}

```

The date I'm inputting with the help of logstash is in this form: MM/dd/yyyy (for example, 04/06/2016), but I keep getting an error saying:  
`Invalid format: \"04/26/2016"\ is malformed \"26/2016"\`

I've also tried to use other things in the mapping, for example:  
"format" : "MM-dd-yyyy"  
"format" : "MM/dd/yyyy"  
And I keep getting the same error.

Do you have a solution for me?

Thanks.

**EDIT:**  
I'm using ES 2.1

---

<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: [April 26, 2016, 7:59am UTC](https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391/2 "2016-04-26T07:59:58Z")

</div>

Not sure what your exact problem is but remember that:

- you have to remove existing index if you want the new mapping to be applied
- you might have to remove the template as well (unsure for this one)

Check your mapping after you get this error. It could give you a clue.

Finally, date optional time is day/month/year IIRC.

---

<div class="post-metadata">

### Author: ![muhamadli302](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@muhamadli302](https://discuss.elastic.co/u/muhamadli302)
#### Post date: [April 26, 2016, 8:10am UTC](https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391/3 "2016-04-26T08:10:39Z")

</div>

Hi, thanks for the response.

I did remove both the index and template after every change I made.

Thanks for clarifying the -date-optional-time format, do you know what I should use for the date I have in my input?

Thanks.

---

<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: [April 26, 2016, 10:39am UTC](https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391/4 "2016-04-26T10:39:44Z")

</div>

I think that what you proposed should work: `"format" : "MM/dd/yyyy"`

---

<div class="post-metadata">

### Author: ![muhamadli302](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@muhamadli302](https://discuss.elastic.co/u/muhamadli302)
#### Post date: [April 26, 2016, 12:16pm UTC](https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391/5 "2016-04-26T12:16:44Z")

</div>

But it doesn't work, still gives me the same error.

---

<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: [April 26, 2016, 12:36pm UTC](https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391/6 "2016-04-26T12:36:38Z")

</div>

What is the full error you are getting?

---

<div class="post-metadata">

### Author: ![muhamadli302](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@muhamadli302](https://discuss.elastic.co/u/muhamadli302)
#### Post date: [April 27, 2016, 5:56am UTC](https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391/7 "2016-04-27T05:56:08Z")

</div>

Here is the error from the elasticsearch log:

```
[2016-04-26 17:35:13,534][DEBUG][action.bulk][Ironclad][template-msg][3] failed to execute bulk item (index) index {template-msg][Content Modification Time][AVTYJTLqXmB4kBUtb7CA],source[{"message":"04/26/2016, Happy Birthday", "@version":"1", "@timestamp":"2016-04-27T05:35:48.294Z","beat":{"hostname":"comp","name":"comp"},"count":1,"fields":null,"input_type":"log","offset":614842169,"date":"04/26/2016", "msg":"Happy Birthday"}]}
MapperParsingException[failed to parse [date]]; nested: IllegalArgumentException[Invalid format: "26/04/2016" is malformed at "/14/2009"];
```

---

<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: [April 27, 2016, 6:19am UTC](https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391/8 "2016-04-27T06:19:41Z")

</div>

What is the mapping for:

```
GET template-msg/_mapping
```

---

<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:56pm UTC](https://discuss.elastic.co/t/date-issue-invalid-format-malformed/48391/9 "2017-07-05T22:56:06Z")

</div>


