# Logstash Filtering Grabbing Partial Date

**URL:** <https://discuss.elastic.co/t/logstash-filtering-grabbing-partial-date/186257>\
**Category:** Logstash\
**Created:** [June 18, 2019, 1:09pm UTC](https://discuss.elastic.co/t/logstash-filtering-grabbing-partial-date/186257 "2019-06-18T13:09:49Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [June 18, 2019, 1:44pm UTC](https://discuss.elastic.co/t/logstash-filtering-grabbing-partial-date/186257/2 "2019-06-18T13:44:18Z")

</div>

Copy it to another field and then

```
mutate { gsub => ["ts", "^(\d{4}-\d{2}-\d{2}T\d{2}).*", "\1"] }

```

We use a capture group () to surround the part of the field we want to keep, and follow that with .\* which will consume everything we do not want to keep. "\1" says to replace the text that the pattern matched (the entire field) with the contents of the first capture group.

---

_[View the full topic](https://discuss.elastic.co/t/logstash-filtering-grabbing-partial-date/186257)._
