# Convert date from string to datetime format

**URL:** https://discuss.elastic.co/t/convert-date-from-string-to-datetime-format/112774
**Category:** Logstash
**Created:** [December 21, 2017, 8:59am UTC](https://discuss.elastic.co/t/convert-date-from-string-to-datetime-format/112774 "2017-12-21T08:59:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![vuxuanlai](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@vuxuanlai](https://discuss.elastic.co/u/vuxuanlai)
#### Post date: [December 21, 2017, 8:59am UTC](https://discuss.elastic.co/t/convert-date-from-string-to-datetime-format/112774/1 "2017-12-21T08:59:22Z")

</div>

Hi there,

I have logstash filter with date as below:

> date {  
> match =\> ["date","MMM dd yyyy HH:mm:ss", "MMM d yyyy HH:mm:ss"]  
> target =\> "date"  
> }

but when i visualize data on kibana, i got "date" field which still got a type is string.

 ![date_string](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7ea4c38f02c86cf56d70cb367deb8371dede548b.PNG)  
So i want to convert "date" field from string to date. How can someone help me?  
Thanks.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [December 21, 2017, 9:06am UTC](https://discuss.elastic.co/t/convert-date-from-string-to-datetime-format/112774/2 "2017-12-21T09:06:17Z")

</div>

The `date` field has already been mapped as string by ES and there's nothing Logstash can do about that. If possible just delete the existing index.

---

<div class="post-metadata">

### Author: ![vuxuanlai](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@vuxuanlai](https://discuss.elastic.co/u/vuxuanlai)
#### Post date: [December 21, 2017, 9:13am UTC](https://discuss.elastic.co/t/convert-date-from-string-to-datetime-format/112774/3 "2017-12-21T09:13:01Z")

</div>

If i delete existing index, my data will be released, date field also.  
You mean there is no way to convert date from string to date when visualize in kibana?

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [December 21, 2017, 9:48am UTC](https://discuss.elastic.co/t/convert-date-from-string-to-datetime-format/112774/4 "2017-12-21T09:48:00Z")

</div>

You can reindex your data, but then you have to make sure to deal with the existing documents whose `date` field isn't recognized as a timestamp by ES. If you just reindex chances are that the `date` field in the first document that's reindexed will be recognized as a string and then your back at square one.

---

<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: [January 18, 2018, 9:48am UTC](https://discuss.elastic.co/t/convert-date-from-string-to-datetime-format/112774/5 "2018-01-18T09:48:50Z")

</div>

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