# Convert string to date in logstash config file

**URL:** <https://discuss.elastic.co/t/convert-string-to-date-in-logstash-config-file/52976>\
**Category:** Logstash\
**Created:** [June 16, 2016, 10:47am UTC](https://discuss.elastic.co/t/convert-string-to-date-in-logstash-config-file/52976 "2016-06-16T10:47:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarbjeet](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sarbjeet](https://discuss.elastic.co/u/sarbjeet)\
**Post date:** [June 16, 2016, 10:47am UTC](https://discuss.elastic.co/t/convert-string-to-date-in-logstash-config-file/52976/1 "2016-06-16T10:47:41Z")

</div>

hi... my csv file is:-  
input {  
stdin {}  
}  
filter {  
csv {  
separator =\> " "  
columns =\> ["frame.time","col.Source","col.Destination","col.Protocol","frame.len"]  
}  
mutate {rename =\> {"frame.time" =\> "Time"}}  
mutate {rename =\> {"col.Source" =\> "Source" }}  
mutate {rename =\> {"col.Destination" =\> "Destination"}}  
mutate {rename =\> {"col.Protocol" =\> "Protocol"}}  
mutate {rename =\> {"frame.len" =\> "Length" }}  
}  
output {  
elasticsearch {  
action =\> "index"  
hosts =\> "localhost"  
index =\> "d"  
workers =\> 1  
}

stdout{

codec =\>rubydebug}

}  
when i run this file ."Time" data type shown in kibana is string but i want to set the data type of "Time" field is date.  
what should i do?

---

<div class="post-metadata">

**Author:** ![sarbjeet](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sarbjeet](https://discuss.elastic.co/u/sarbjeet)\
**Post date:** [June 16, 2016, 11:21am UTC](https://discuss.elastic.co/t/convert-string-to-date-in-logstash-config-file/52976/2 "2016-06-16T11:21:34Z")

</div>

output when i run config file:-  
"message" =\> "May 2, 2013 07:32:15.227019000\t115.165.168.105\t202.141.75.170\tTCP\t66",  
"@version" =\> "1",  
"@timestamp" =\> "2016-06-16T11:14:51.341Z",  
"host" =\> "sab-VirtualBox",  
"Time" =\> "May 2, 2013 07:32:15.227019000",  
"Source" =\> "115.165.168.105",  
"Destination" =\> "202.141.75.170",  
"Protocol" =\> "TCP",  
"Length" =\> "66",  
"tags" =\> [  
[0] "\_dateparsefailure"  
]

i want timestamp take my Time field value or time field should be date type.

---

<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:** [June 17, 2016, 5:43am UTC](https://discuss.elastic.co/t/convert-string-to-date-in-logstash-config-file/52976/3 "2016-06-17T05:43:04Z")

</div>

I suggest you use a date filter to parse the contents of the `Time` field and turn it into something that ES can recognize as a timestamp.

---

<div class="post-metadata">

**Author:** ![sarbjeet](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sarbjeet](https://discuss.elastic.co/u/sarbjeet)\
**Post date:** [June 17, 2016, 11:32am UTC](https://discuss.elastic.co/t/convert-string-to-date-in-logstash-config-file/52976/4 "2016-06-17T11:32:08Z")

</div>

Thanks for Help.  
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:** [July 6, 2017, 4:52am UTC](https://discuss.elastic.co/t/convert-string-to-date-in-logstash-config-file/52976/5 "2017-07-06T04:52:13Z")

</div>


