# Date format error with "epoch\_millis||epoch\_second"

**URL:** <https://discuss.elastic.co/t/date-format-error-with-epoch-millis-epoch-second/101135>\
**Category:** Elasticsearch\
**Created:** [September 20, 2017, 8:45am UTC](https://discuss.elastic.co/t/date-format-error-with-epoch-millis-epoch-second/101135 "2017-09-20T08:45:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kabali12345](https://avatars.discourse-cdn.com/v4/letter/k/6a8cbe/32.png) [@kabali12345](https://discuss.elastic.co/u/kabali12345)\
**Post date:** [September 20, 2017, 8:45am UTC](https://discuss.elastic.co/t/date-format-error-with-epoch-millis-epoch-second/101135/1 "2017-09-20T08:45:47Z")

</div>

Hi all....  
Here i am trying to define mapping for a field which stores epoch date values in it.

```auto
PUT my_index11
{
  "mappings": {
    "my_type": {
      "properties": {
        "date": {
          "type": "date",
           "format": "epoch_millis||epoch_second"
        }
      }
    }
  }
}

```

where in my mapping i have defined two Built In Formats they are **epoch\_millis||epoch\_second**  
but the problem is when i insert a document with date value in epoch\_millis

```auto
PUT my_index11/my_type/1
{ "date": 1505894323000 }

```

i am able to find a doc 1 in discovery page of kibana but when i insert a document with date value in epoch\_second

```auto
PUT my_index11/my_type/2
{ "date": 1420070400 }

```

i have not find second doc i.e, doc 2 in kibana discovery page but i able to see it in index

Please help me with this

Thank You.

---

<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:** [September 20, 2017, 9:33am UTC](https://discuss.elastic.co/t/date-format-error-with-epoch-millis-epoch-second/101135/2 "2017-09-20T09:33:14Z")

</div>

I suspect the second document is being indexed with the date "Saturday, 17 January 1970 10:27:50.400". The reason for this is that dates in the `epoch_second` format also look like they are in `epoch_milli` since neither format is fixed width. When Elasticsearch indexes a document it tries the formats in the order you specify in the mapping and stops when it reaches the first format that succeeds which means that it will first try `epoch_milli` that will always match succeed since `1420070400` is a valid `epoch_milli` timestamp (though not the timestamp you intend).

I think you'll need to solve this upstream in your indexing pipeline and normalise all your dates to `epoch_millis`. Presumably a particular data source is consistent with the format it sends so it may just be that you need to add logic to your indexing application that converts the dates to `epoch_milli` if it is from the data sources that send `epoch_second`

---

<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:** [October 18, 2017, 9:33am UTC](https://discuss.elastic.co/t/date-format-error-with-epoch-millis-epoch-second/101135/3 "2017-10-18T09:33:30Z")

</div>

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