# Capture date and time from a sentence

**URL:** <https://discuss.elastic.co/t/capture-date-and-time-from-a-sentence/181017>\
**Category:** Logstash\
**Created:** [May 14, 2019, 2:14pm UTC](https://discuss.elastic.co/t/capture-date-and-time-from-a-sentence/181017 "2019-05-14T14:14:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhilash\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhilash_b/32/40270_2.png) [@Abhilash\_B](https://discuss.elastic.co/u/Abhilash_B)\
**Post date:** [May 14, 2019, 2:14pm UTC](https://discuss.elastic.co/t/capture-date-and-time-from-a-sentence/181017/1 "2019-05-14T14:14:10Z")

</div>

Hi,

I have this sentence, `The deployment started 3/19/2019 at 2:05` as a `"message"` to logstash  
How do I capture the date and time in the above sentence? Also, how should I check to allow this sentence to be parsed and other sentences be ignored. I was thinking something on the lines of:

```
if [message] =~ /^The deployment started/ {
    ruby{
        <some code here to parse date and time>
    }
}

```

Any help here is appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 14, 2019, 3:12pm UTC](https://discuss.elastic.co/t/capture-date-and-time-from-a-sentence/181017/2 "2019-05-14T15:12:09Z")

</div>

Why not a grok or dissect filter?

---

<div class="post-metadata">

**Author:** ![Abhilash\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhilash_b/32/40270_2.png) [@Abhilash\_B](https://discuss.elastic.co/u/Abhilash_B)\
**Post date:** [May 14, 2019, 5:00pm UTC](https://discuss.elastic.co/t/capture-date-and-time-from-a-sentence/181017/3 "2019-05-14T17:00:19Z")

</div>

Hey David,

Can you give an example? Would be really helpful.

Thanks.

---

<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:** [May 14, 2019, 5:35pm UTC](https://discuss.elastic.co/t/capture-date-and-time-from-a-sentence/181017/4 "2019-05-14T17:35:03Z")

</div>

> [@Abhilash\_B](#):
>
> The deployment started 3/19/2019 at 2:05

A dissect would be as simple as

```
dissect { mapping => { "message" => "The deployment started %{date} at %{time}" } }

```

---

<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:** [June 11, 2019, 5:35pm UTC](https://discuss.elastic.co/t/capture-date-and-time-from-a-sentence/181017/5 "2019-06-11T17:35:13Z")

</div>

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