# Exclude or replace a specific date value with null value

**URL:** https://discuss.elastic.co/t/exclude-or-replace-a-specific-date-value-with-null-value/139803
**Category:** Logstash
**Created:** [July 12, 2018, 5:20pm UTC](https://discuss.elastic.co/t/exclude-or-replace-a-specific-date-value-with-null-value/139803 "2018-07-12T17:20:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![imaad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/imaad/32/48628_2.png) [@imaad](https://discuss.elastic.co/u/imaad)
#### Post date: [July 12, 2018, 5:20pm UTC](https://discuss.elastic.co/t/exclude-or-replace-a-specific-date-value-with-null-value/139803/1 "2018-07-12T17:20:58Z")

</div>

I'm using a jms input to index data from queues, some fields contains two values ("2018-07-12T23:30:00.000+0000" and "2018-07-12T00:00:00.000+0000") that I have to replace with null value. How can I resolve this?

Thank you

---

<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: [July 12, 2018, 6:16pm UTC](https://discuss.elastic.co/t/exclude-or-replace-a-specific-date-value-with-null-value/139803/2 "2018-07-12T18:16:41Z")

</div>

Does this work for you?

```
    if [somefield] == "2018-07-12T23:30:00.000+0000" or [somefield] == "2018-07-12T00:00:00.000+0000" {
        ruby { code => 'event.set("somefield", nil)' }
    }

```

Or perhaps

```
mutate { gsub => ["somefield", "2018-07-12T(23:30|00:00):00.000\+0000", ""] }

```

depending on what you mean by null.

---

<div class="post-metadata">

### Author: ![imaad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/imaad/32/48628_2.png) [@imaad](https://discuss.elastic.co/u/imaad)
#### Post date: [July 13, 2018, 8:48am UTC](https://discuss.elastic.co/t/exclude-or-replace-a-specific-date-value-with-null-value/139803/3 "2018-07-13T08:48:06Z")

</div>

Hello @Badger,

Thank you for your response, it works for me.  
Do you have an idea about how to generalize this, I mean instead of 2018-07-12 I want to replace it by today ( so as to match today : "todayT23:30:00.000+0000"). I tried something like that, but it doesn't work :

> if [scheduled\_trigger\_date] == "%{+YYYY-MM-dd}T23:30:00.000+0000" or [scheduled\_trigger\_date] == "%{+YYYY-MM-dd}T00:00:00.000+0000" {  
> ruby { code =\> 'event.set("scheduled\_trigger\_date", nil)' }  
> }

Thank you

---

<div class="post-metadata">

### Author: ![imaad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/imaad/32/48628_2.png) [@imaad](https://discuss.elastic.co/u/imaad)
#### Post date: [July 13, 2018, 9:12am UTC](https://discuss.elastic.co/t/exclude-or-replace-a-specific-date-value-with-null-value/139803/4 "2018-07-13T09:12:07Z")

</div>

I resolve it.  
I post the solution for someone who will face the same problem :

> mutate {  
> add\_field =\> {  
> "replace\_scheduled\_trigger1" =\> "%{+YYYY-MM-dd}T23:30:00.000+0000"  
> "replace\_scheduled\_trigger2" =\> "%{+YYYY-MM-dd}T00:00:00.000+0000"  
> }  
> }  
> if [scheduled\_trigger\_date] == [replace\_scheduled\_trigger1] or [scheduled\_trigger\_date] == [replace\_scheduled\_trigger2] {  
> ruby { code =\> 'event.set("scheduled\_trigger\_date", nil)' }  
> }

---

<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: [August 10, 2018, 9:12am UTC](https://discuss.elastic.co/t/exclude-or-replace-a-specific-date-value-with-null-value/139803/5 "2018-08-10T09:12:11Z")

</div>

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