# Transform a field

**URL:** <https://discuss.elastic.co/t/transform-a-field/78504>\
**Category:** Logstash\
**Created:** [March 14, 2017, 11:39am UTC](https://discuss.elastic.co/t/transform-a-field/78504 "2017-03-14T11:39:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@Mohamed](https://discuss.elastic.co/u/Mohamed)\
**Post date:** [March 14, 2017, 11:39am UTC](https://discuss.elastic.co/t/transform-a-field/78504/1 "2017-03-14T11:39:46Z")

</div>

Hello,

I have a field that is created from xml file with xpath formula :

"time": "2017-03-03T16:48:28.933+01:00" (`<time>2017-03-03T16:48:28.933+01:00<'/time>` in xml input).

I want to create a nested field like this :

"time": "2017-03-03 16:48:28"

where i am wrong please suggest

```
ruby {
			code => '
			b = event["step_start_date"].split("T")[0];
			for c in b ;
			f= c.split(".")[0];				
			end;
			event.set("step_start_date", "%{b} %{f}")
				'
		}

```

Thank you for help.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 14, 2017, 2:30pm UTC](https://discuss.elastic.co/t/transform-a-field/78504/2 "2017-03-14T14:30:32Z")

</div>

You don't need a ruby filter for this. The mutate filter's gsub option is enough. Replace the T with a space and replace the milliseconds and timezone with nothing.

---

<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:** [April 11, 2017, 2:30pm UTC](https://discuss.elastic.co/t/transform-a-field/78504/3 "2017-04-11T14:30:43Z")

</div>

Closed on April 11, 2017, 2:30pm UTC

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