# Remove space from date string

**URL:** <https://discuss.elastic.co/t/remove-space-from-date-string/151671>\
**Category:** Logstash\
**Created:** [October 9, 2018, 3:27pm UTC](https://discuss.elastic.co/t/remove-space-from-date-string/151671 "2018-10-09T15:27:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CraigFoote](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/craigfoote/32/4571_2.png) [@CraigFoote](https://discuss.elastic.co/u/CraigFoote)\
**Post date:** [October 9, 2018, 3:27pm UTC](https://discuss.elastic.co/t/remove-space-from-date-string/151671/1 "2018-10-09T15:27:04Z")

</div>

I have a field named 'datetime' that is a string with a space between the date and the time (ISO8601 with a space instead of a 'T'). I need the date portion to use in another field. I've tried this:

mutate{  
add\_field =\> { "date\_only" =\> "%{datetime}" }  
gsub =\> ["date\_only", " .\*", ""]  
}

I've also tried for the gsub pattern "\s.\*" and doubleslash+s but in all cases the time is not removed from date\_only. What am I doing wrong?

Craig

---

<div class="post-metadata">

**Author:** ![CraigFoote](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/craigfoote/32/4571_2.png) [@CraigFoote](https://discuss.elastic.co/u/CraigFoote)\
**Post date:** [October 19, 2018, 4:09pm UTC](https://discuss.elastic.co/t/remove-space-from-date-string/151671/2 "2018-10-19T16:09:15Z")

</div>

The solution was to break the steps up into two mutate blocks.

---

<div class="post-metadata">

**Author:** ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)\
**Post date:** [October 24, 2018, 9:31pm UTC](https://discuss.elastic.co/t/remove-space-from-date-string/151671/3 "2018-10-24T21:31:56Z")

</div>

I've run into this same issue mutliple times. It appears that the order of operations as input into the config file does not matter. Each plugin appears to perform its specific operations first and then common operations are performed last. It would be nice if plugins performed operations based on how they are entered into the config file but I could also see that opening a whole can of worms for a lot of people.

---

<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:** [November 21, 2018, 9:31pm UTC](https://discuss.elastic.co/t/remove-space-from-date-string/151671/4 "2018-11-21T21:31:57Z")

</div>

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