<?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: How to change time into seconds? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364958#M161185</link>
    <description>&lt;P&gt;have you tried the convert function?&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.5.3/SearchReference/Convert"&gt;https://docs.splunk.com/Documentation/Splunk/6.5.3/SearchReference/Convert&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;you might first need to put all the time into the same format first if they aren't all in &lt;CODE&gt;M:SS&lt;/CODE&gt; (for instance it looks like the first one is just :&lt;CODE&gt;SS&lt;/CODE&gt;)&lt;/P&gt;</description>
    <pubDate>Fri, 05 May 2017 13:02:38 GMT</pubDate>
    <dc:creator>cmerriman</dc:creator>
    <dc:date>2017-05-05T13:02:38Z</dc:date>
    <item>
      <title>How to change time into seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364957#M161184</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;

&lt;P&gt;Please help me out to convert time format into seconds.&lt;/P&gt;

&lt;P&gt;My time field has values like :07, 7:45.&lt;/P&gt;

&lt;P&gt;Example:&lt;BR /&gt;
:07 = 7 secs&lt;BR /&gt;
7:45= 465 sec&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;BR /&gt;
Nikks&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 11:42:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364957#M161184</guid>
      <dc:creator>nilaksh92</dc:creator>
      <dc:date>2017-05-05T11:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to change time into seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364958#M161185</link>
      <description>&lt;P&gt;have you tried the convert function?&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.5.3/SearchReference/Convert"&gt;https://docs.splunk.com/Documentation/Splunk/6.5.3/SearchReference/Convert&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;you might first need to put all the time into the same format first if they aren't all in &lt;CODE&gt;M:SS&lt;/CODE&gt; (for instance it looks like the first one is just :&lt;CODE&gt;SS&lt;/CODE&gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 13:02:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364958#M161185</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-05-05T13:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to change time into seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364959#M161186</link>
      <description>&lt;P&gt;Function Needed:&lt;/P&gt;

&lt;P&gt;dur2sec()&lt;BR /&gt;
Syntax: dur2sec()&lt;BR /&gt;
Description: Convert a duration format "[D+]HH:MM:SS" to seconds. You can use wild card characters in the field name.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 14:18:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364959#M161186</guid>
      <dc:creator>jordanb93</dc:creator>
      <dc:date>2017-05-05T14:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to change time into seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364960#M161187</link>
      <description>&lt;P&gt;This assumes that the data can also contain hour:min:sec.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval mydata=":01 56:23 3:12:15"| makemv mydata | mvexpand mydata
| rename COMMENT as "The above just makes test data"

| rex field=mydata "(?&amp;lt;myHourOrMin&amp;gt;[^:]+)?:?(?&amp;lt;myMin&amp;gt;[^:]+)?:(?&amp;lt;mySec&amp;gt;\d+)"
| eval seconds=3600*if(isnull(myMin),0,coalesce(myHourOrMin,0))+60*coalesce(myMin,myHourOrMin,0)+coalesce(mySec,0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it can only contain minutes and seconds, then this simpler version will meet the need...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval mydata=":01 56:23 2:15 :42 "| makemv mydata | mvexpand mydata
| rename COMMENT as "The above just makes test data"

| rex field=mydata "(?&amp;lt;myMin&amp;gt;[^:]+)?:(?&amp;lt;mySec&amp;gt;\d+)"
| eval seconds=60*coalesce(myMin,0)+coalesce(mySec,0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... and here's another way, that pretty much works for anything...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval mydata=":01 56:23 2:15 :42 "| makemv mydata | mvexpand mydata
| rename COMMENT as "The above just makes test data"

| rex field=mydata "(?&amp;lt;myHourOrMin&amp;gt;[^:]+)?:?(?&amp;lt;myMin&amp;gt;[^:]+)?:(?&amp;lt;mySec&amp;gt;\d+)"
| eval seconds=3600*if(isnull(myMin),0,coalesce(myHourOrMin,0))+60*coalesce(myMin,myHourOrMin,0)+coalesce(mySec,0)

| rename COMMENT as "Here's another way..."
| eval mydata2 = substr("00:00:00",1,8-len(mydata)).mydata
| convert dur2sec(mydata2) as seconds2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 May 2017 14:55:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364960#M161187</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-05T14:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to change time into seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364961#M161188</link>
      <description>&lt;P&gt;Actually dur2sec() requires the hour and minute, so see the very last example in my answer for how to make it work in this case.  &lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 14:49:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364961#M161188</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-09T14:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to change time into seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364962#M161189</link>
      <description>&lt;P&gt;Thanks DalJeanis.&lt;/P&gt;

&lt;P&gt;It worked. Thanks for your kind help.&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 06:26:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-time-into-seconds/m-p/364962#M161189</guid>
      <dc:creator>nilaksh92</dc:creator>
      <dc:date>2017-05-11T06:26:42Z</dc:date>
    </item>
  </channel>
</rss>

