# Convert a field string to time

**URL:** <https://discuss.elastic.co/t/convert-a-field-string-to-time/113339>\
**Category:** Logstash\
**Created:** [December 27, 2017, 4:36pm UTC](https://discuss.elastic.co/t/convert-a-field-string-to-time/113339 "2017-12-27T16:36:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivek\_Nigam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_nigam/32/25094_2.png) [@Vivek\_Nigam](https://discuss.elastic.co/u/Vivek_Nigam)\
**Post date:** [December 27, 2017, 4:36pm UTC](https://discuss.elastic.co/t/convert-a-field-string-to-time/113339/1 "2017-12-27T16:36:43Z")

</div>

Hi,

my string value is like 03:40:15 , want to convert it to time field without date.

can i do it??

---

<div class="post-metadata">

**Author:** ![arisbanach](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@arisbanach](https://discuss.elastic.co/u/arisbanach)\
**Post date:** [December 27, 2017, 4:39pm UTC](https://discuss.elastic.co/t/convert-a-field-string-to-time/113339/2 "2017-12-27T16:39:58Z")

</div>

I think date fields need the actual date as well as time or else they wouldn't be able to be plotted on a chart or understood very well. I would say a workaround to this would be to add a date to it like 1970-01-01.

---

<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:** [December 29, 2017, 11:13am UTC](https://discuss.elastic.co/t/convert-a-field-string-to-time/113339/3 "2017-12-29T11:13:37Z")

</div>

The ES date type represents an absolute time so just omitting the date won't work. If you describe what you want to accomplish with a time-only field maybe we can make a suggestion.

---

<div class="post-metadata">

**Author:** ![Vivek\_Nigam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_nigam/32/25094_2.png) [@Vivek\_Nigam](https://discuss.elastic.co/u/Vivek_Nigam)\
**Post date:** [December 29, 2017, 12:48pm UTC](https://discuss.elastic.co/t/convert-a-field-string-to-time/113339/4 "2017-12-29T12:48:52Z")

</div>

Hi,

I have a process, where i want to show total time taken to complete the process like 03:34:25 without date.i take it to string value, but in kibana i cannot show string value in Y Axis.

can i take value 03:34:25 as integer, i try but it store only first value:03, even cannot store value as float. same situation.

---

<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:** [December 31, 2017, 1:02pm UTC](https://discuss.elastic.co/t/convert-a-field-string-to-time/113339/5 "2017-12-31T13:02:47Z")

</div>

How long something has taken isn't a time, it's a duration. You'll want to store that data as an integer (representing the number of seconds or milliseconds). I don't think there's an out of the box plugin for doing this so you'll have to write a piece of Ruby code in a ruby filter.

---

<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:** [January 28, 2018, 1:02pm UTC](https://discuss.elastic.co/t/convert-a-field-string-to-time/113339/6 "2018-01-28T13:02:52Z")

</div>

Closed on January 28, 2018, 1:02pm UTC

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