# How to create a date field target with date {}?

**URL:** <https://discuss.elastic.co/t/how-to-create-a-date-field-target-with-date/58043>\
**Category:** Logstash\
**Created:** [August 15, 2016, 5:21pm UTC](https://discuss.elastic.co/t/how-to-create-a-date-field-target-with-date/58043 "2016-08-15T17:21:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [August 15, 2016, 5:21pm UTC](https://discuss.elastic.co/t/how-to-create-a-date-field-target-with-date/58043/1 "2016-08-15T17:21:03Z")

</div>

I am parsing my logs date using this filter:

date {  
match =\> ["datetime", "YYYY-MM-dd HH:mm:ss.SSS"]  
target =\> "datetime"  
}

but the new "datetime" field is created of type string. How can it be created of type date?

I cant use the default @timestamp because NEST library doesnt retrieve it ok

---

<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:** [August 15, 2016, 7:50pm UTC](https://discuss.elastic.co/t/how-to-create-a-date-field-target-with-date/58043/2 "2016-08-15T19:50:22Z")

</div>

It should get mapped as a date, at least in the format produced by the date filter. Perhaps it was mapped as a string before you had the date filter in place? The first document you sent maybe had a timestamp in a format that wasn't recognized as a date and therefore the field was mapped as a string.

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [August 18, 2016, 6:50pm UTC](https://discuss.elastic.co/t/how-to-create-a-date-field-target-with-date/58043/3 "2016-08-18T18:50:03Z")

</div>

yes i deleted index and next time it was created it was mapped right as time. thanks!

---

<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:42am UTC](https://discuss.elastic.co/t/how-to-create-a-date-field-target-with-date/58043/4 "2017-07-06T04:42:41Z")

</div>


