# Converting a string date to a Date field using scripted fields in kibana

**URL:** https://discuss.elastic.co/t/converting-a-string-date-to-a-date-field-using-scripted-fields-in-kibana/108952
**Category:** Kibana
**Created:** [November 24, 2017, 2:43am UTC](https://discuss.elastic.co/t/converting-a-string-date-to-a-date-field-using-scripted-fields-in-kibana/108952 "2017-11-24T02:43:17Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [November 24, 2017, 7:25am UTC](https://discuss.elastic.co/t/converting-a-string-date-to-a-date-field-using-scripted-fields-in-kibana/108952/2 "2017-11-24T07:25:05Z")

</div>

I would really suggest against that if you have more than just a few records of data. You should reindex your data and make sure date time is stored correctly. Doing this with scripted fields will be painfully slow. Not 100% but i guess elastic will always have to go over every record and do conversion and then return the subset you are interested in.

that being said, if you look at painless reference: [https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-api-reference.html](https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-api-reference.html)

you can see it supports SimpleDateFormat

looking at oracle documentation: [https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html](https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html)

something like this should work:

```auto
 new SimpleDateFormat('dd/MMM/yyyy:HH:mm:ss Z').parse(doc['fieldname'].value); 

```

---

_[View the full topic](https://discuss.elastic.co/t/converting-a-string-date-to-a-date-field-using-scripted-fields-in-kibana/108952)._
