<?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 Calculate Seconds that are over 60 minutes, to Days, Hours, Minutes, Seconds in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29196#M177901</link>
    <description>&lt;P&gt;I have an issue with calculating seconds that go over 60 minutes that sums to be a few days.&lt;/P&gt;

&lt;P&gt;One of my eval calculations sums to be 496089.166322 seconds and if I use&lt;BR /&gt;
|fieldformat "Total Time"=strftime('Total Time', "%M:%S") I get 48:09 as the sum but should calculate to 5 days, 17 hours, 48 minutes and 9 seconds&lt;/P&gt;

&lt;P&gt;I am not sure if I have to use a macro to do the job? &lt;A href="http://splunk-base.splunk.com/answers/61652/convert-seconds-into-hours-minutes-and-seconds?page=1&amp;amp;focusedAnswerId=61657#61657" target="_blank"&gt;LINK&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Or missing something obvious?&lt;/P&gt;

&lt;P&gt;I have searched through every variation of this and have tried all the common date and time format variables with strftime( converts epoch time to format Y )&lt;/P&gt;

&lt;P&gt;Here is my current search string where I have to break down the Days Hours Minutes and Seconds along with a &lt;A href="http://www.itsuperman.com/Splunk/time-miscalc.png" target="_blank"&gt;ScreenCapture&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Search String:&lt;/P&gt;

&lt;P&gt;index="snort"&lt;BR /&gt;
( 2222222 dest_port="&lt;EM&gt;") OR (1111111 src_port="&lt;/EM&gt;") OR ( 1111111 src_ip="&lt;EM&gt;") OR (2222222 dest_ip="&lt;/EM&gt;")&lt;BR /&gt;
| eval disconnect_time=if(match(_raw,"2222222"),_time,null()) &lt;BR /&gt;
| eval connect_time=if(match(_raw,"1111111"),_time,null())&lt;BR /&gt;
| eval Ephemeral=if(isnotnull(disconnect_time),dest_port,Ephemeral) &lt;BR /&gt;
| eval Ephemeral=if(isnotnull(connect_time),src_port,Ephemeral)&lt;BR /&gt;
| stats min(connect_time) as Connect max(disconnect_time) as Disconnect min(src_ip) as "Source IP" by Ephemeral&lt;BR /&gt;
| eval Seconds=Disconnect-Connect &lt;BR /&gt;
| fieldformat "Seconds"=strftime('Seconds', "%s") &lt;BR /&gt;
| eval Minutes=Seconds/60 | eval Hours=Minutes/60 &lt;BR /&gt;
| eval Days=Hours/24&lt;BR /&gt;
| convert timeformat="%a %b-%d %Y "at" %H:%M:%S" ctime(Connect) ctime(Disconnect) &lt;BR /&gt;
| search Connect=* Disconnect=* &lt;BR /&gt;
| rename Ephemeral as "Connection Port", Total_time as "lala"&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 13:18:14 GMT</pubDate>
    <dc:creator>Xe03kfp</dc:creator>
    <dc:date>2020-09-28T13:18:14Z</dc:date>
    <item>
      <title>Calculate Seconds that are over 60 minutes, to Days, Hours, Minutes, Seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29196#M177901</link>
      <description>&lt;P&gt;I have an issue with calculating seconds that go over 60 minutes that sums to be a few days.&lt;/P&gt;

&lt;P&gt;One of my eval calculations sums to be 496089.166322 seconds and if I use&lt;BR /&gt;
|fieldformat "Total Time"=strftime('Total Time', "%M:%S") I get 48:09 as the sum but should calculate to 5 days, 17 hours, 48 minutes and 9 seconds&lt;/P&gt;

&lt;P&gt;I am not sure if I have to use a macro to do the job? &lt;A href="http://splunk-base.splunk.com/answers/61652/convert-seconds-into-hours-minutes-and-seconds?page=1&amp;amp;focusedAnswerId=61657#61657" target="_blank"&gt;LINK&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Or missing something obvious?&lt;/P&gt;

&lt;P&gt;I have searched through every variation of this and have tried all the common date and time format variables with strftime( converts epoch time to format Y )&lt;/P&gt;

&lt;P&gt;Here is my current search string where I have to break down the Days Hours Minutes and Seconds along with a &lt;A href="http://www.itsuperman.com/Splunk/time-miscalc.png" target="_blank"&gt;ScreenCapture&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Search String:&lt;/P&gt;

&lt;P&gt;index="snort"&lt;BR /&gt;
( 2222222 dest_port="&lt;EM&gt;") OR (1111111 src_port="&lt;/EM&gt;") OR ( 1111111 src_ip="&lt;EM&gt;") OR (2222222 dest_ip="&lt;/EM&gt;")&lt;BR /&gt;
| eval disconnect_time=if(match(_raw,"2222222"),_time,null()) &lt;BR /&gt;
| eval connect_time=if(match(_raw,"1111111"),_time,null())&lt;BR /&gt;
| eval Ephemeral=if(isnotnull(disconnect_time),dest_port,Ephemeral) &lt;BR /&gt;
| eval Ephemeral=if(isnotnull(connect_time),src_port,Ephemeral)&lt;BR /&gt;
| stats min(connect_time) as Connect max(disconnect_time) as Disconnect min(src_ip) as "Source IP" by Ephemeral&lt;BR /&gt;
| eval Seconds=Disconnect-Connect &lt;BR /&gt;
| fieldformat "Seconds"=strftime('Seconds', "%s") &lt;BR /&gt;
| eval Minutes=Seconds/60 | eval Hours=Minutes/60 &lt;BR /&gt;
| eval Days=Hours/24&lt;BR /&gt;
| convert timeformat="%a %b-%d %Y "at" %H:%M:%S" ctime(Connect) ctime(Disconnect) &lt;BR /&gt;
| search Connect=* Disconnect=* &lt;BR /&gt;
| rename Ephemeral as "Connection Port", Total_time as "lala"&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:18:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29196#M177901</guid>
      <dc:creator>Xe03kfp</dc:creator>
      <dc:date>2020-09-28T13:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Seconds that are over 60 minutes, to Days, Hours, Minutes, Seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29197#M177902</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I think that you have to use "tostring" on the eval command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval "Total Time"=tostring(Seconds,"duration")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result of that command is 5+17:48:09.166322 &lt;BR /&gt;
where "5+" is the number of days.&lt;/P&gt;

&lt;P&gt;I hope this help you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2013 18:28:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29197#M177902</guid>
      <dc:creator>jaraneda</dc:creator>
      <dc:date>2013-02-12T18:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Seconds that are over 60 minutes, to Days, Hours, Minutes, Seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29198#M177903</link>
      <description>&lt;P&gt;Yes that worked!  To make it pretty..is there a way to take away the miliseconds?  Also, how would I sum the "Total Seonds" as a "Total Time" like:  | transpose | "Total Time" string --so the total time shows left justified?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2013 18:39:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29198#M177903</guid>
      <dc:creator>Xe03kfp</dc:creator>
      <dc:date>2013-02-12T18:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Seconds that are over 60 minutes, to Days, Hours, Minutes, Seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29199#M177904</link>
      <description>&lt;P&gt;I found addcoltotals gives me a total in seconds for the field I specify, then I will have to convert the seconds.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2013 19:09:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29199#M177904</guid>
      <dc:creator>Xe03kfp</dc:creator>
      <dc:date>2013-02-12T19:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Seconds that are over 60 minutes, to Days, Hours, Minutes, Seconds</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29200#M177905</link>
      <description>&lt;P&gt;Can you get the amount of days on its own?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2013 09:34:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-Seconds-that-are-over-60-minutes-to-Days-Hours-Minutes/m-p/29200#M177905</guid>
      <dc:creator>Oisin77</dc:creator>
      <dc:date>2013-11-27T09:34:55Z</dc:date>
    </item>
  </channel>
</rss>

