# Date format in my sql

**URL:** <https://discuss.elastic.co/t/date-format-in-my-sql/240182>\
**Category:** Logstash\
**Created:** [July 7, 2020, 3:09pm UTC](https://discuss.elastic.co/t/date-format-in-my-sql/240182 "2020-07-07T15:09:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [July 7, 2020, 3:09pm UTC](https://discuss.elastic.co/t/date-format-in-my-sql/240182/1 "2020-07-07T15:09:08Z")

</div>

I have tried to parse data from mysql into elk stack i have date column which has date format 2020-04-01 00:00:01 and 2020-06-25 13:36:24 but when i parse the data the date is not showing in date format its still showing in string field. My configuration file is  
input {  
jdbc {  
jdbc\_connection\_string =\> "jdbc:mysql://localhost:3306/NBP"  
jdbc\_user =\> "_**"  
jdbc\_password =\> "**"  
jdbc\_driver\_library =\> "/etc/logstash/mysql-connector-java-8.0.16.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
statement =\> "SELECT \* FROM ` ****** l`"  
use\_column\_value =\> true  
tracking\_column =\> "id"  
clean\_run =\> true  
last\_run\_metadata\_path =\> ".logstash\_jdbc\_last\_run"  
jdbc\_paging\_enabled =\> true  
jdbc\_page\_size =\> "5000"  
}  
}  
output {  
elasticsearch {  
hosts =\> "\*\*\*\*\*\*\*\*"  
index =\> "_\*\*\*"  
document\_id =\> "%{id}"  
}  
stdout{  
codec =\> rubydebug  
}  
}

---

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [July 11, 2020, 6:53pm UTC](https://discuss.elastic.co/t/date-format-in-my-sql/240182/2 "2020-07-11T18:53:10Z")

</div>

You'll either have to configure the mapping of your index to define your date field as a date data type in ES that accepts this date format or use a date filter in Logstash to parse the date. (I'd suggest doing the latter.) Either way you'll have to reindex your data because you can't change the mapping of an existing index.

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [July 16, 2020, 6:12am UTC](https://discuss.elastic.co/t/date-format-in-my-sql/240182/3 "2020-07-16T06:12:02Z")

</div>

Thanks for the reply i create date field with datetime datetype and it works

---

<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 13, 2020, 6:12am UTC](https://discuss.elastic.co/t/date-format-in-my-sql/240182/4 "2020-08-13T06:12:04Z")

</div>

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