# Date mapping issue - Invalid format ... malformed

**URL:** https://discuss.elastic.co/t/date-mapping-issue-invalid-format-malformed/34546
**Category:** Elasticsearch
**Created:** [November 13, 2015, 6:16pm UTC](https://discuss.elastic.co/t/date-mapping-issue-invalid-format-malformed/34546 "2015-11-13T18:16:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![marinoc](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@marinoc](https://discuss.elastic.co/u/marinoc)
#### Post date: [November 13, 2015, 6:16pm UTC](https://discuss.elastic.co/t/date-mapping-issue-invalid-format-malformed/34546/1 "2015-11-13T18:16:52Z")

</div>

I have a couple date fields that aren't recognized by ES, and thus causing this Invalid Format issue.

The format is : MM/dd/YYYY (e.g. 11/13/2015)

Here is the error from the ES logs:

```
    [2015-11-13 13:07:47,830][DEBUG][action.bulk] [toph] [hardball-parks][0] failed to execute bulk item (index) index {[hardball-parks][baseballpark][BAL03], source[{"message":["BAL03~Oriole Park I~~Baltimore~MD~05/01/1883~10/10/1889~AA~\"\""],"@version":"1","@timestamp":"2015-11-13T18:07:46.481Z","type":"baseballpark","baseballParkID":"BAL03","parkName":"Oriole Park I","parkAka":null,"parkCity":"Baltimore","parkState":"MD","parkStartDate":"05/01/1883","parkEndDate":"10/10/1889","parkLeague":"AA","parkNotes":""}]}
    MapperParsingException[failed to parse [parkStartDate]]; nested: IllegalArgumentException[Invalid format: "05/01/1883" is malformed at "/01/1883"];
    	at org.elasticsearch.index.mapper.FieldMapper.parse(FieldMapper.java:339)
...
    Caused by: java.lang.IllegalArgumentException: Invalid format: "05/01/1883" is malformed at "/01/1883"
    	at org.joda.time.format.DateTimeParserBucket.doParseMillis(DateTimeParserBucket.java:187)
    	at org.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:780)
    	at org.elasticsearch.index.mapper.core.DateFieldMapper$DateFieldType.parseStringValue(DateFieldMapper.java:360)
    	at org.elasticsearch.index.mapper.core.DateFieldMapper.innerParseCreateField(DateFieldMapper.java:526)
    	at org.elasticsearch.index.mapper.core.NumberFieldMapper.parseCreateField(NumberFieldMapper.java:213)
    	at org.elasticsearch.index.mapper.FieldMapper.parse(FieldMapper.java:331)
    	... 20 more

```

Here's a sample event from the Logstash rubydebug codec:

```
{
           "message" => [
        [0] "BAL03~Oriole Park I~~Baltimore~MD~05/01/1883~10/10/1889~AA~\"\""
    ],
          "@version" => "1",
        "@timestamp" => "2015-11-13T17:40:11.734Z",
              "type" => "baseballpark",
    "baseballParkID" => "BAL03",
          "parkName" => "Oriole Park I",
           "parkAka" => nil,
          "parkCity" => "Baltimore",
         "parkState" => "MD",
     "parkStartDate" => "05/01/1883",
       "parkEndDate" => "10/10/1889",
        "parkLeague" => "AA",
         "parkNotes" => ""
}

```

And finally, here are my ES mappings for this index:

```
{
  "hardball-parks": {
    "mappings": {
      "baseballPark": {
        "dynamic": "true",
        "include_in_all": false,
        "_all": {
          "enabled": false
        },
        "properties": {
          "baseballParkID": {
            "type": "string",
            "index": "not_analyzed",
            "include_in_all": false
          },
          "parkAka": {
            "type": "string",
            "include_in_all": false
          },
          "parkCity": {
            "type": "string",
            "index": "not_analyzed",
            "include_in_all": false
          },
          "parkEndDate": {
            "type": "date",
            "format": "MM/dd/YYYY",
            "include_in_all": false
          },
          "parkLeague": {
            "type": "string",
            "index": "not_analyzed",
            "include_in_all": false
          },
          "parkName": {
            "type": "string",
            "include_in_all": false
          },
          "parkNotes": {
            "type": "string",
            "include_in_all": false
          },
          "parkStartDate": {
            "type": "date",
            "format": "MM/dd/YYYY",
            "include_in_all": false
          },
          "parkState": {
            "type": "string",
            "index": "not_analyzed",
            "include_in_all": false
          }
        }
      }
    }
  }
}

```

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: [August 22, 2016, 9:37am UTC](https://discuss.elastic.co/t/date-mapping-issue-invalid-format-malformed/34546/3 "2016-08-22T09:37:17Z")

</div>

Don't use old threads. Use your own and eventually link to the old one.

Here:

```
2016-08-22 13:53:28 

```

is not

```
yyyy/MM/dd'T'HH:mm:ss
```

---

<div class="post-metadata">

### Author: ![G\_Prasath](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@G\_Prasath](https://discuss.elastic.co/u/G_Prasath)
#### Post date: [August 22, 2016, 10:05am UTC](https://discuss.elastic.co/t/date-mapping-issue-invalid-format-malformed/34546/4 "2016-08-22T10:05:54Z")

</div>

Your format doesn't conform with Built-in formats of Elastic Search 2.3! Please refer 'Built In Formats' under [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html)

I did face exactly the same issue! But I tweaked my PHP time object's format to be in accordance with Elastic Search Mapping!

Curl command to create mapping for the the field 'ClickTime' in a standard format :

curl -XPUT localhost:9200/telemetry/\_mapping/DashBoardVisits?  
pretty -d "{"properties" : {"ClickTime" : {"type" :"date" , "format" :  
"yyyy-MM-dd HH:mm:ss" }}}"  
PHP code to create a time object matching the type and format of 'ClickTime' in Elastic Search :

$curtime = date\_create();  
$kibanadate = date\_format($curtime,"Y-m-d H:i:s");

---

<div class="post-metadata">

### Author: ![G\_Prasath](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@G\_Prasath](https://discuss.elastic.co/u/G_Prasath)
#### Post date: [August 22, 2016, 10:08am UTC](https://discuss.elastic.co/t/date-mapping-issue-invalid-format-malformed/34546/5 "2016-08-22T10:08:00Z")

</div>

I have made necessary changes. Can we please delete the comment? This is no more valid now.

---

<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:26pm UTC](https://discuss.elastic.co/t/date-mapping-issue-invalid-format-malformed/34546/6 "2017-07-05T22:26:13Z")

</div>


