# Add a new date field from existing String

**URL:** <https://discuss.elastic.co/t/add-a-new-date-field-from-existing-string/164669>\
**Category:** Logstash\
**Created:** [January 17, 2019, 3:31pm UTC](https://discuss.elastic.co/t/add-a-new-date-field-from-existing-string/164669 "2019-01-17T15:31:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kimkong](https://avatars.discourse-cdn.com/v4/letter/k/dec6dc/32.png) [@kimkong](https://discuss.elastic.co/u/kimkong)\
**Post date:** [January 17, 2019, 3:31pm UTC](https://discuss.elastic.co/t/add-a-new-date-field-from-existing-string/164669/1 "2019-01-17T15:31:55Z")

</div>

Hello everybody,

i am totally new in elastic and hope you can show me an easy solution.😀  
i want to add a new date field.  
The date is already existing in the file-name, so its written in the source field already.  
It looks like this C:\test1\test2\test3\20180715.txt

So the date would be 15.07.2018.

How can i extract this date and show it as a new date field ?

Thanks a lot,  
Kim

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 17, 2019, 3:58pm UTC](https://discuss.elastic.co/t/add-a-new-date-field-from-existing-string/164669/2 "2019-01-17T15:58:15Z")

</div>

Well, you could use [grok](https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html) to extract the date using a pattern like

```
"[\\]%{NUMBER:date}\."

```

Then use a [date](https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html) filter to parse it against "YYYYMMdd".

---

<div class="post-metadata">

**Author:** ![kimkong](https://avatars.discourse-cdn.com/v4/letter/k/dec6dc/32.png) [@kimkong](https://discuss.elastic.co/u/kimkong)\
**Post date:** [January 18, 2019, 10:59am UTC](https://discuss.elastic.co/t/add-a-new-date-field-from-existing-string/164669/3 "2019-01-18T10:59:32Z")

</div>

Thanks, works fine !😀

---

<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:** [February 15, 2019, 10:59am UTC](https://discuss.elastic.co/t/add-a-new-date-field-from-existing-string/164669/4 "2019-02-15T10:59:33Z")

</div>

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