Splunk Search

How to get the duration in the format HH:MM:SS between two extracted fields (DateTimeStart and DateTimeEnd)?

shariinPH
Contributor

hello guys,

I have two extracted fields which are DateTimeStart and DateTimeEnd
So I get the minimum time started and the maximum time ended by the field jobname

|stats min(DateTimeStart) as DateTimeStart max(DateTimeEnd) as DateTimeEnd by jobname

For example:
My min time for start is DateTimeStart: 03/24/2015 06:00:35
and for the max end time i have here DateTimeEnd: 03/24/2015 06:15:03

So my question is, how to get the duration and with the format Hours:Minutes:Seconds

Thanks guys :">

1 Solution

shariinPH
Contributor

i already figured it out.

|convert mktime(DateTimeStart) as dtstart mktime(DateTimeEnd) as dtend
|eval dur=(dtend-dtstart)
|eval myduration=tostring(dur,"duration")

hope this helps you as well! 🙂
Cheers!

View solution in original post

shariinPH
Contributor

i already figured it out.

|convert mktime(DateTimeStart) as dtstart mktime(DateTimeEnd) as dtend
|eval dur=(dtend-dtstart)
|eval myduration=tostring(dur,"duration")

hope this helps you as well! 🙂
Cheers!

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...