<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Converting Duration Field value to seconds in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199790#M57878</link>
    <description>&lt;P&gt;The accepted answer should now be changed to this response since it is now a thing. SOOOO much cleaner and easier.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Sep 2015 20:32:20 GMT</pubDate>
    <dc:creator>MattZerfas</dc:creator>
    <dc:date>2015-09-04T20:32:20Z</dc:date>
    <item>
      <title>Converting Duration Field value to seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199784#M57872</link>
      <description>&lt;P&gt;I have a extracted field call CallDuration and in logs it in format&lt;/P&gt;

&lt;P&gt;%H:%M:%S.%2N like 00:00:38.60&lt;/P&gt;

&lt;P&gt;That means the call duartion was 38.60 secs.&lt;/P&gt;

&lt;P&gt;Now how can i convert that duartion to total number of seconds.??&lt;/P&gt;

&lt;P&gt;If field value is 01:05:45.20&lt;BR /&gt;
The new field should hold total duration in seconds ie. 3945.20sec&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 11:24:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199784#M57872</guid>
      <dc:creator>adityapavan18</dc:creator>
      <dc:date>2014-03-27T11:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Duration Field value to seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199785#M57873</link>
      <description>&lt;P&gt;Here's something to get you started:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval duration=strptime(CallDuration,"%H:%M:%S.%2N") | eval base=strptime("00:00:00.00","%H:%M:%S.%2N") | eval secs=duration-base | table duration, secs
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Mar 2014 12:07:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199785#M57873</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-03-27T12:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Duration Field value to seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199786#M57874</link>
      <description>&lt;P&gt;Hi adityapavan18,&lt;/P&gt;

&lt;P&gt;the following searchFu are example and you need to match them to your events, but you could do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field="_raw" "CallDuration: (?&amp;lt;hours&amp;gt;\d+)h:(?&amp;lt;minutes&amp;gt;\d+)m:(?&amp;lt;seconds&amp;gt;\d+)s" | eval CallDurationInSeconds = ((hours*60*60)+(minutes*60)+(seconds))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or something like this if you have duration over or under one day:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field="_raw" "CallDuration: (?&amp;lt;dur_day&amp;gt;[0-9]+)?d? *(?&amp;lt;dur_hour&amp;gt;[0-9]+)h?:(?&amp;lt;dur_min&amp;gt;[0-9]+)m?" | eval connduration=(if(dur_day=="",0,dur_day)*1440*60)+(dur_hour * 60*60)+(dur_min*60)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 12:18:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199786#M57874</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-03-27T12:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Duration Field value to seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199787#M57875</link>
      <description>&lt;P&gt;that's a nice one as well and I was typing for to long &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 12:20:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199787#M57875</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-03-27T12:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Duration Field value to seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199788#M57876</link>
      <description>&lt;P&gt;If you have many places where this conversion will take place, I would suggest to create a macro for it.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 13:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199788#M57876</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-03-27T13:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Duration Field value to seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199789#M57877</link>
      <description>&lt;P&gt;There's now a convert function for this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | convert dur2sec(CallDuration) AS duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jun 2015 20:47:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199789#M57877</guid>
      <dc:creator>gpullis</dc:creator>
      <dc:date>2015-06-10T20:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Duration Field value to seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199790#M57878</link>
      <description>&lt;P&gt;The accepted answer should now be changed to this response since it is now a thing. SOOOO much cleaner and easier.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2015 20:32:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199790#M57878</guid>
      <dc:creator>MattZerfas</dc:creator>
      <dc:date>2015-09-04T20:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Duration Field value to seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199791#M57879</link>
      <description>&lt;P&gt;totally agree&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 14:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199791#M57879</guid>
      <dc:creator>MedralaG</dc:creator>
      <dc:date>2017-07-28T14:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Duration Field value to seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199792#M57880</link>
      <description>&lt;P&gt;This answer is not valid, dur2sec does not support milliseconds. Proof: index=* | head 1 | eval CallDuration="00:00:38.60" | convert dur2sec(CallDuration) AS duration -&amp;gt; results in no duration field.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 22:36:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Duration-Field-value-to-seconds/m-p/199792#M57880</guid>
      <dc:creator>bugmenot</dc:creator>
      <dc:date>2018-07-19T22:36:35Z</dc:date>
    </item>
  </channel>
</rss>

