# Multiple date formats to single date format

**URL:** <https://discuss.elastic.co/t/multiple-date-formats-to-single-date-format/169327>\
**Category:** Kibana\
**Created:** [February 21, 2019, 5:19am UTC](https://discuss.elastic.co/t/multiple-date-formats-to-single-date-format/169327 "2019-02-21T05:19:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gauravb](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@gauravb](https://discuss.elastic.co/u/gauravb)\
**Post date:** [February 21, 2019, 5:19am UTC](https://discuss.elastic.co/t/multiple-date-formats-to-single-date-format/169327/1 "2019-02-21T05:19:41Z")

</div>

I have multiple date format in kibana say **Y-M-D , M-D-Y, D-M-Y and Y/M/D**  
I want to change them to single format say **Y-M-D**

Please help me with the painless script  
**Index name is Case**  
**Field name is Decision\_date**

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [February 21, 2019, 7:51pm UTC](https://discuss.elastic.co/t/multiple-date-formats-to-single-date-format/169327/2 "2019-02-21T19:51:18Z")

</div>

Hi, I'm not sure how to do this in Painless, but the documentation on Elasticsearch date format might help: [format | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html)

> In JSON documents, dates are represented as strings. Elasticsearch uses a set of preconfigured formats to recognize and parse these strings into a long value representing _milliseconds-since-the-epoch_ in UTC.

So if the field is correctly mapped as date format, then the Painless script should be able to use the raw value of milliseconds since the epoch. You shouldn't have to worry about the format of the string in the \_source

---

<div class="post-metadata">

**Author:** ![gauravb](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@gauravb](https://discuss.elastic.co/u/gauravb)\
**Post date:** [February 22, 2019, 2:18pm UTC](https://discuss.elastic.co/t/multiple-date-formats-to-single-date-format/169327/3 "2019-02-22T14:18:39Z")

</div>

I dont think I get what you said. What should I do again ?

---

<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:** [March 22, 2019, 2:18pm UTC](https://discuss.elastic.co/t/multiple-date-formats-to-single-date-format/169327/4 "2019-03-22T14:18:59Z")

</div>

Closed on March 22, 2019, 2:18pm UTC

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