<?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: Calculate time difference / duration not showing correct results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601574#M209365</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229059"&gt;@neerajs_81&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;all the time calculations must be done on numbers, so the tostring option is good to display a duration in human readable format, but it isn't good for calculations.&lt;/P&gt;&lt;P&gt;So make calculations before the tostring transformation, as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;hinted:&lt;/P&gt;&lt;P&gt;if you want a duration greater one hour you have to calculate something like this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval condition=if(duration&amp;gt;3600),"More than 1 hour","Less than 1 hour")&lt;/LI-CODE&gt;&lt;P&gt;If this or another one answer solves your need, please, accept it for the other people of Community.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the Contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jun 2022 14:37:22 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2022-06-13T14:37:22Z</dc:date>
    <item>
      <title>How to calculate time difference / duration not showing correct results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601532#M209346</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp; &amp;nbsp;I need to calculate the duration i.e. difference between endtime &amp;amp; starttime and display the same in a user friendly format.&amp;nbsp; I have looked at different posts on the forum and am using the same logic yet if you see my splunk results below,&amp;nbsp; the duration column shows numbers like 81, 82 , 96... which doesn't make sense.&amp;nbsp; &amp;nbsp;Are these difference in secs ? Even if its secs, the math doesn't seem to be correct.&amp;nbsp; &amp;nbsp; How can I make diff value show in a readable format like&amp;nbsp; 81 seconds, or&amp;nbsp; 00:00:81 ( HH:MM:SS) ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| transaction eventID startswith=starting endswith=end 
| eval starttime = _time | eval endtime=_time+duration
| eval duration = endtime-starttime
| convert ctime(starttime)| convert ctime(endtime) 
| table starttime, endtime, duraton&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neerajs_81_0-1655122704866.png" style="width: 429px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20056i404C83B12FC5B515/image-dimensions/429x981?v=v2" width="429" height="981" role="button" title="neerajs_81_0-1655122704866.png" alt="neerajs_81_0-1655122704866.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 20:13:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601532#M209346</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-06-13T20:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference / duration not showing correct results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601533#M209347</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229059"&gt;@neerajs_81&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;di you explored the use of tostring option?&lt;/P&gt;&lt;P&gt;somthing like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| transaction eventID startswith=starting endswith=end 
| eval starttime = _time | eval endtime=_time+duration
| eval duration = tostring(endtime-starttime,"duration")
| convert ctime(starttime)| convert ctime(endtime) 
| table starttime, endtime, duraton&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 12:24:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601533#M209347</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-06-13T12:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference / duration not showing correct results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601560#M209359</link>
      <description>&lt;P&gt;You are the man !!!.&amp;nbsp; Thank you.&lt;BR /&gt;One more related question,&amp;nbsp; now that we have the duration calculated, how do i enable a condition to check if duration &amp;gt; N hours or N mins ?&amp;nbsp; &amp;nbsp;Basically i need to filter for events where duration is past 1 hour say.&amp;nbsp; Will the below where clause work ? Doesn't appear to be&amp;nbsp; working&lt;BR /&gt;&lt;BR /&gt;| where duration &amp;gt; 00:60:00&amp;nbsp; &amp;nbsp;OR | where duration &amp;gt; 60&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neerajs_81_0-1655128894949.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20058i07C6115826FD230A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="neerajs_81_0-1655128894949.png" alt="neerajs_81_0-1655128894949.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 14:03:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601560#M209359</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-06-13T14:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference / duration not showing correct results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601566#M209361</link>
      <description>&lt;P&gt;Have your where command before the tostring() function remembering that the value will be in seconds, so use 3600 for 1 hour.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 14:13:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601566#M209361</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-06-13T14:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference / duration not showing correct results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601569#M209363</link>
      <description>&lt;P&gt;It does make perfect sense.&lt;/P&gt;&lt;P&gt;14:17:06 + 82 seconds = 14:18:06+22 seconds = 14:18:28&lt;/P&gt;&lt;P&gt;And so on.&lt;/P&gt;&lt;P&gt;I'd also advise to not use eval to convert from this seconds-based duration to string but use fieldformat. This way you retain the possibility to do any manipulation you want but you'll present the time to the user in a readable way.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 14:17:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601569#M209363</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-06-13T14:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference / duration not showing correct results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601574#M209365</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229059"&gt;@neerajs_81&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;all the time calculations must be done on numbers, so the tostring option is good to display a duration in human readable format, but it isn't good for calculations.&lt;/P&gt;&lt;P&gt;So make calculations before the tostring transformation, as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;hinted:&lt;/P&gt;&lt;P&gt;if you want a duration greater one hour you have to calculate something like this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval condition=if(duration&amp;gt;3600),"More than 1 hour","Less than 1 hour")&lt;/LI-CODE&gt;&lt;P&gt;If this or another one answer solves your need, please, accept it for the other people of Community.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the Contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 14:37:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-duration-not-showing-correct/m-p/601574#M209365</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-06-13T14:37:22Z</dc:date>
    </item>
  </channel>
</rss>

