<?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 How to format 86401 seconds as 24:00:01 in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242041#M72008</link>
    <description>&lt;P&gt;I am trying to display a duration result to a dashboard and when I try to use the function to convert seconds to HH:MM:SS format like this:&lt;BR /&gt;
index="ourlogs"  | eval OurNameDDHHMMSS=tostring(OurVariable, "duration") &lt;/P&gt;

&lt;P&gt;Anything over 24 hours (86400 seconds) the result I see is 1+00:00:01.  When I do a search and I ask for the top 2 (using head 2)  I am getting the 23:00:00 numbers returned instead of anything with the 1+ format.  I also think for the people who look at the dashboard it would be easier for them to see it as 24:00:01.  &lt;/P&gt;

&lt;P&gt;Any suggestions or links would be appreciated.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jan 2016 18:57:53 GMT</pubDate>
    <dc:creator>SammyDavis</dc:creator>
    <dc:date>2016-01-22T18:57:53Z</dc:date>
    <item>
      <title>How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242041#M72008</link>
      <description>&lt;P&gt;I am trying to display a duration result to a dashboard and when I try to use the function to convert seconds to HH:MM:SS format like this:&lt;BR /&gt;
index="ourlogs"  | eval OurNameDDHHMMSS=tostring(OurVariable, "duration") &lt;/P&gt;

&lt;P&gt;Anything over 24 hours (86400 seconds) the result I see is 1+00:00:01.  When I do a search and I ask for the top 2 (using head 2)  I am getting the 23:00:00 numbers returned instead of anything with the 1+ format.  I also think for the people who look at the dashboard it would be easier for them to see it as 24:00:01.  &lt;/P&gt;

&lt;P&gt;Any suggestions or links would be appreciated.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2016 18:57:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242041#M72008</guid>
      <dc:creator>SammyDavis</dc:creator>
      <dc:date>2016-01-22T18:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242042#M72009</link>
      <description>&lt;P&gt;84600 seconds is actually 23:30.  I think you mean 86400.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jan 2016 01:49:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242042#M72009</guid>
      <dc:creator>grijhwani</dc:creator>
      <dc:date>2016-01-23T01:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242043#M72010</link>
      <description>&lt;P&gt;You can sort based on time in seconds and then convert it to duration to keep the sorting correct. If you still want to show time HH:MM:SS instead of D+HH:MM:SS, then you can calculate and concatenate each part separately.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jan 2016 22:47:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242043#M72010</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-01-23T22:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242044#M72011</link>
      <description>&lt;P&gt;I was honestly surprised at how hard this was.  That usually means I'm doing it wrong, but I did find a way to do it.   I too have noticed this behavior, but it affects our data very little so I haven't "fixed" it.  That being said, you just gave me incentive.&lt;/P&gt;

&lt;P&gt;Try this run-anywhere search.  In it you should have all bits and pieces you need.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=10/1/15 end=10/5/15 
| eval test=86401 
| eval secs=test%60 | eval mins=floor((test/60)%60) | eval hrs=floor((test/3600)%60)
| eval f_hrs=if(len(hrs)=1,"0".tostring(hrs), tostring(hrs))
| eval f_mins=if(len(mins)=1,"0".tostring(mins), tostring(mins))
| eval f_secs=if(len(secs)=1,"0".tostring(secs), tostring(secs))
| eval result=f_hrs.":".f_mins.":".f_secs
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My naming: &lt;CODE&gt;test&lt;/CODE&gt; is the value I'm testing (use your own variable there).  &lt;CODE&gt;secs&lt;/CODE&gt;, &lt;CODE&gt;mins&lt;/CODE&gt; and &lt;CODE&gt;hrs&lt;/CODE&gt; are the converted hours, minutes and seconds from the test value.  &lt;CODE&gt;f_*&lt;/CODE&gt; are the "formatted" converted values (e.g. adding a leading zero when necessary) and the &lt;CODE&gt;result&lt;/CODE&gt; is just concatenating those values together.&lt;/P&gt;

&lt;P&gt;NOTES:  This is nasty.  I tried to tame it as best I could, but I'm sure this code would make fun of your grandmother and try to kick your puppy if it was given a chance.  I tried convert(), but it seems that "Hours" in Splunk are less than 24, regardless of your desires.  That makes total sense for times but not necessarily for durations.&lt;/P&gt;

&lt;P&gt;I will be putting in an Enhancement Request for some option to convert durations without that implicit day-conversion.  On a good day I can read numbers well into the upper two digits (like even all the way up to 73!), so changing "27" into "1 day plus 3 hours" isn't always helpful.  &lt;/P&gt;</description>
      <pubDate>Sun, 24 Jan 2016 01:44:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242044#M72011</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-01-24T01:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242045#M72012</link>
      <description>&lt;P&gt;Correct thanks&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 17:41:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242045#M72012</guid>
      <dc:creator>SammyDavis</dc:creator>
      <dc:date>2016-01-26T17:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242046#M72013</link>
      <description>&lt;P&gt;Thanks very much for your help, this did work to display it in the format I wanted and give me the results I was looking for.  As one of my teachers liked to tell me over and over again "working code is good code" so I am sure this one would avoid kicking any puppies, but not sure about not making fun of grandmothers.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 18:18:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242046#M72013</guid>
      <dc:creator>SammyDavis</dc:creator>
      <dc:date>2016-01-26T18:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242047#M72014</link>
      <description>&lt;P&gt;Hey , &lt;BR /&gt;
I got same problem but instead of 86401 sec I have 580397 sec, as per rich7177 answered I am getting 41:13:17  as result , because when I convert 580397sec to HH:MM:SS I am getting   6 days 17:13:17  as answer. So tell me how to solve this problem. &lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 13:13:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242047#M72014</guid>
      <dc:creator>erritesh17</dc:creator>
      <dc:date>2017-07-11T13:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242048#M72015</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;This is another easiest way to do it :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=10/1/15 end=10/5/15 
| eval test=86401
| eval Hour = floor(test/3600)
| eval test = strftime(test,"%M:%S")
| eval result = Hour.":".test
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2017 13:40:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242048#M72015</guid>
      <dc:creator>KailA</dc:creator>
      <dc:date>2017-07-11T13:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242049#M72016</link>
      <description>&lt;P&gt;| eval ts="580397"  | convert rmunit(ts) as numSecs  | eval stringSecs=tostring(numSecs,"duration") | eval stringSecs=case(stringSecs="00:00:00", "0+0:0:0", 0=0, stringSecs) | eval stringSecs = replace(stringSecs,"(\d+):(\d+):(\d+)","\1h \2min \3s") | table ts stringSecs&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 14:01:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242049#M72016</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2017-07-11T14:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242050#M72017</link>
      <description>&lt;P&gt;Really no need to do all those format conversions.  &lt;CODE&gt;strftime&lt;/CODE&gt; will do most of the work, even if the duration in seconds has not been labeled as such.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval ts=580397
| eval hours = floor(ts/3600)
| eval tshoursformatted=hours.":".strftime(ts-3600*hours,"%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or, if you prefer the result in days...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval ts=580397
| eval days = floor(ts/86400)
| eval tsdaysformatted=days." days + ".strftime(ts-86400*days,"%H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2017 14:23:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242050#M72017</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-11T14:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242051#M72018</link>
      <description>&lt;P&gt;@KailA - Really close, but you need to use &lt;CODE&gt;floor&lt;/CODE&gt; instead of &lt;CODE&gt;round&lt;/CODE&gt;.  Otherwise, half the time you will get the wrong number of hours.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 14:25:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242051#M72018</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-11T14:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242052#M72019</link>
      <description>&lt;P&gt;You're right ! My bad &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 15:00:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/242052#M72019</guid>
      <dc:creator>KailA</dc:creator>
      <dc:date>2017-07-11T15:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/594303#M206841</link>
      <description>&lt;P&gt;You do not want the %60 in:&lt;/P&gt;&lt;PRE&gt;| eval hrs=floor((test/3600)%60)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise a duration of 66 hours will become 06 hours...&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 15:31:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/594303#M206841</guid>
      <dc:creator>gabriel_vasseur</dc:creator>
      <dc:date>2022-04-19T15:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to format 86401 seconds as 24:00:01</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/594355#M206864</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/205010"&gt;@Richfez&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;printf is a useful eval func here to do the formatting&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval result=printf("%02d:%02d:%02d", floor(test/3600), floor((test/60)%60), test%60)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 19 Apr 2022 23:29:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-86401-seconds-as-24-00-01/m-p/594355#M206864</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-04-19T23:29:40Z</dc:date>
    </item>
  </channel>
</rss>

