# Invalid date because milliseconds does not contains trailing zeros

**URL:** <https://discuss.elastic.co/t/invalid-date-because-milliseconds-does-not-contains-trailing-zeros/189874>\
**Category:** Elasticsearch\
**Created:** [July 10, 2019, 9:13pm UTC](https://discuss.elastic.co/t/invalid-date-because-milliseconds-does-not-contains-trailing-zeros/189874 "2019-07-10T21:13:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thiago\_Coimbra\_Lemos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago_coimbra_lemos/32/49834_2.png) [@Thiago\_Coimbra\_Lemos](https://discuss.elastic.co/u/Thiago_Coimbra_Lemos)\
**Post date:** [July 10, 2019, 9:13pm UTC](https://discuss.elastic.co/t/invalid-date-because-milliseconds-does-not-contains-trailing-zeros/189874/1 "2019-07-10T21:13:25Z")

</div>

* * *

**TL;DR;**

Valid: 2019-07-10T17:01:01.500Z  
Valid: 2019-07-10T17:01:01.50Z  
**INVALID** : 2019-07-10T17:01:01.5Z

**I want to know how to accept the invalid value as a valid value, since it is a valid date value.**

* * *

I'm trying to add a document that contains a date property, if this property has a time with a rounded milliseconds that results in only one digit, it causes the following error:

```
{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse field [value_at] of type [date] in document with id '1'"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse field [value_at] of type [date] in document with id '1'",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "failed to parse date field [2019-07-10T17:01:01.5Z] with format [strict_date_optional_time||epoch_millis]",
      "caused_by": {
        "type": "date_time_parse_exception",
        "reason": "Failed to parse with all enclosed parsers"
      }
    }
  },
  "status": 400
}

```

Steps to reproduce:

```
PUT my_index/_doc/1
{
  "value_at": "2019-07-10T17:01:01.500Z"
}

PUT my_index/_doc/1
{
  "value_at": "2019-07-10T17:01:01.5Z"
}

```

Mapping generated by the first **PUT** :

```
{
  "my_index" : {
    "aliases" : { },
    "mappings" : {
      "properties" : {
        "value_at" : {
          "type" : "date"
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1562792878369",
        "number_of_shards" : "1",
        "number_of_replicas" : "1",
        "uuid" : "gXOZiC0PTFuQKaOwdeoyig",
        "version" : {
          "created" : "7000199"
        },
        "provided_name" : "my_index"
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![Thiago\_Coimbra\_Lemos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago_coimbra_lemos/32/49834_2.png) [@Thiago\_Coimbra\_Lemos](https://discuss.elastic.co/u/Thiago_Coimbra_Lemos)\
**Post date:** [July 13, 2019, 2:45am UTC](https://discuss.elastic.co/t/invalid-date-because-milliseconds-does-not-contains-trailing-zeros/189874/2 "2019-07-13T02:45:33Z")

</div>

Is it possible to get some help here??? 🤔

---

<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 13, 2019, 6:00am UTC](https://discuss.elastic.co/t/invalid-date-because-milliseconds-does-not-contains-trailing-zeros/189874/3 "2019-07-13T06:00:58Z")

</div>

I have no idea. Which version is that?

---

<div class="post-metadata">

**Author:** ![Thiago\_Coimbra\_Lemos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago_coimbra_lemos/32/49834_2.png) [@Thiago\_Coimbra\_Lemos](https://discuss.elastic.co/u/Thiago_Coimbra_Lemos)\
**Post date:** [July 13, 2019, 3:38pm UTC](https://discuss.elastic.co/t/invalid-date-because-milliseconds-does-not-contains-trailing-zeros/189874/4 "2019-07-13T15:38:17Z")

</div>

Hey @dadoonet, thanks for the interest in the topic.

Both ElasticSearch and Kibana are runing 7.0.1 version.

---

<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 13, 2019, 7:46pm UTC](https://discuss.elastic.co/t/invalid-date-because-milliseconds-does-not-contains-trailing-zeros/189874/5 "2019-07-13T19:46:03Z")

</div>

Could you try with 7.2 in case something has been fixed in the meantime?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [July 13, 2019, 8:06pm UTC](https://discuss.elastic.co/t/invalid-date-because-milliseconds-does-not-contains-trailing-zeros/189874/6 "2019-07-13T20:06:59Z")

</div>

@Thiago_Coimbra_Lemos

Hi just ran this all in 7.2.0 all ran fine...

```
PUT my_index/_doc/1
{
  "value_at": "2019-07-10T17:01:01.500Z"
}

GET my_index
   {
      "my_index" : {
        "aliases" : { },
        "mappings" : {
          "properties" : {
            "value_at" : {
              "type" : "date"
            }
          }
        },
        "settings" : {
          "index" : {
            "creation_date" : "1563048120913",
            "number_of_shards" : "1",
            "number_of_replicas" : "1",
            "uuid" : "2WuVHjLyTXSHx2fzeQDRCg",
            "version" : {
              "created" : "7020099"
            },
            "provided_name" : "my_index"
          }
        }
      }
    }

PUT my_index/_doc/2
{
  "value_at": "2019-07-10T17:01:01.50Z"
}

PUT my_index/_doc/3
{
  "value_at": "2019-07-10T17:01:01.5Z"
}

GET my_index/_search
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "my_index",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "value_at" : "2019-07-10T17:01:01.500Z"
        }
      },
      {
        "_index" : "my_index",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "value_at" : "2019-07-10T17:01:01.50Z"
        }
      },
      {
        "_index" : "my_index",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "value_at" : "2019-07-10T17:01:01.5Z"
        }
      }
    ]
  }
}

```

If you are tied to that version you could probably use logstash and some logic to parse / fix before sending to Elasticsearch

---

<div class="post-metadata">

**Author:** ![Thiago\_Coimbra\_Lemos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago_coimbra_lemos/32/49834_2.png) [@Thiago\_Coimbra\_Lemos](https://discuss.elastic.co/u/Thiago_Coimbra_Lemos)\
**Post date:** [July 15, 2019, 4:03pm UTC](https://discuss.elastic.co/t/invalid-date-because-milliseconds-does-not-contains-trailing-zeros/189874/7 "2019-07-15T16:03:24Z")

</div>

Just confirmed that this is working in 7.2.0.

We will update to this version.

Thanks @stephenb and @dadoonet.

---

<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 12, 2019, 4:03pm UTC](https://discuss.elastic.co/t/invalid-date-because-milliseconds-does-not-contains-trailing-zeros/189874/8 "2019-08-12T16:03:29Z")

</div>

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