# Convert string format to date using filter in logstash

**URL:** <https://discuss.elastic.co/t/convert-string-format-to-date-using-filter-in-logstash/157108>\
**Category:** Logstash\
**Created:** [November 16, 2018, 5:01pm UTC](https://discuss.elastic.co/t/convert-string-format-to-date-using-filter-in-logstash/157108 "2018-11-16T17:01:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [November 16, 2018, 5:01pm UTC](https://discuss.elastic.co/t/convert-string-format-to-date-using-filter-in-logstash/157108/1 "2018-11-16T17:01:23Z")

</div>

filter {  
mutate {  
add\_field =\> {  
"docid" =\> "%{projectname}%{systemtypeid}%{username}-%{+dd-MM-YYYY}"  
"daymonthyear" =\> "%{+dd-MM-YYYY}"  
}  
}

I get two variable docid (which I am using as my document\_id =\>  
second is daymonthyear. it gets inserted in to index but type of that filed is string. How do I make it to date.

I just want that variable to be date format in my index.

I try many different option none works as I don't even know how to do it.

Try this under filter but it won't even start logstash.  
date {  
match =\> '["daymonthyear", "dd-MM-YYYY"]  
}

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [November 16, 2018, 5:26pm UTC](https://discuss.elastic.co/t/convert-string-format-to-date-using-filter-in-logstash/157108/2 "2018-11-16T17:26:15Z")

</div>

I just found typo and it works now.

here is config

filter {  
mutate {  
add\_field =\> {  
"docid" =\> "%{projectname}%{systemtypeid}%{username}-%{+dd-MM-YYYY}"  
"daymonthyear" =\> "%{+dd-MM-YYYY}"  
}  
} # Mutate  
date {  
match =\> ["daymonthyear", "dd-MM-YYYY"]  
target =\> "daymonthyear"  
}  
}

### this creates two new variable (filed) and one of them is type date.

---

<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:** [December 14, 2018, 5:35pm UTC](https://discuss.elastic.co/t/convert-string-format-to-date-using-filter-in-logstash/157108/3 "2018-12-14T17:35:20Z")

</div>

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