<?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 Convert duration time to number integer in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708300#M239536</link>
    <description>&lt;P&gt;I have this search, where I get the duration and I need to convert it to integer:&lt;BR /&gt;Example:&lt;/P&gt;
&lt;P&gt;Min:Sec to Whole&lt;/P&gt;
&lt;P&gt;00:02 &amp;nbsp; &amp;nbsp;&amp;nbsp; to &amp;nbsp; 1&lt;BR /&gt;00:16 &amp;nbsp; &amp;nbsp;&amp;nbsp; to &amp;nbsp; 1&lt;BR /&gt;01:53&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to&amp;nbsp; 2&lt;BR /&gt;09:20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to&amp;nbsp; 10&lt;/P&gt;
&lt;P&gt;...etc&lt;/P&gt;
&lt;P&gt;Script:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index="cdr" | search "Call.TermParty.TrunkGroup.TrunkGroupId"="2811" OR
"Call.TermParty.TrunkGroup.TrunkGroupId"="2810"
"Call.ConnectTime"=*
"Call.DisconnectTime"=*
|lookup Pais Call.RoutingInfo.DestAddr OUTPUT Countrie
| eval Disctime=strftime('Call.DisconnectTime'/1000,"%m/%d/%Y %H:%M:%S %Q")
| eval Conntime=strftime('Call.ConnectTime'/1000, "%m/%d/%Y %H:%M:%S%Q")
| eval diffTime=('Call.DisconnectTime'-'Call.ConnectTime')
| eval Duracion=strftime(diffTime/1000, "%M:%S") | table Countrie, Duración

Spain 00:02
Spain 00:16
Argentina 00:53
Spain 09:20
Spain 02:54
Spain 28:30
Spain 01:18
Spain 00:28
Spain 16:40
Spain 00:03
Chile 00:25
Uruguay 01:54
Spain 01:54&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Miguel3393_0-1736370753385.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/34074i5A506B095CB64F77/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Miguel3393_0-1736370753385.png" alt="Miguel3393_0-1736370753385.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jan 2025 23:17:12 GMT</pubDate>
    <dc:creator>Miguel3393</dc:creator>
    <dc:date>2025-01-08T23:17:12Z</dc:date>
    <item>
      <title>Convert duration time to number integer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708300#M239536</link>
      <description>&lt;P&gt;I have this search, where I get the duration and I need to convert it to integer:&lt;BR /&gt;Example:&lt;/P&gt;
&lt;P&gt;Min:Sec to Whole&lt;/P&gt;
&lt;P&gt;00:02 &amp;nbsp; &amp;nbsp;&amp;nbsp; to &amp;nbsp; 1&lt;BR /&gt;00:16 &amp;nbsp; &amp;nbsp;&amp;nbsp; to &amp;nbsp; 1&lt;BR /&gt;01:53&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to&amp;nbsp; 2&lt;BR /&gt;09:20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to&amp;nbsp; 10&lt;/P&gt;
&lt;P&gt;...etc&lt;/P&gt;
&lt;P&gt;Script:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index="cdr" | search "Call.TermParty.TrunkGroup.TrunkGroupId"="2811" OR
"Call.TermParty.TrunkGroup.TrunkGroupId"="2810"
"Call.ConnectTime"=*
"Call.DisconnectTime"=*
|lookup Pais Call.RoutingInfo.DestAddr OUTPUT Countrie
| eval Disctime=strftime('Call.DisconnectTime'/1000,"%m/%d/%Y %H:%M:%S %Q")
| eval Conntime=strftime('Call.ConnectTime'/1000, "%m/%d/%Y %H:%M:%S%Q")
| eval diffTime=('Call.DisconnectTime'-'Call.ConnectTime')
| eval Duracion=strftime(diffTime/1000, "%M:%S") | table Countrie, Duración

Spain 00:02
Spain 00:16
Argentina 00:53
Spain 09:20
Spain 02:54
Spain 28:30
Spain 01:18
Spain 00:28
Spain 16:40
Spain 00:03
Chile 00:25
Uruguay 01:54
Spain 01:54&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Miguel3393_0-1736370753385.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/34074i5A506B095CB64F77/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Miguel3393_0-1736370753385.png" alt="Miguel3393_0-1736370753385.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 23:17:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708300#M239536</guid>
      <dc:creator>Miguel3393</dc:creator>
      <dc:date>2025-01-08T23:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Convert duration time to number integer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708303#M239539</link>
      <description>How about ceil for diffTime?&lt;BR /&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.4.0/SearchReference/MathematicalFunctions#ceiling.28.26lt.3Bnum.26gt.3B.29_or_ceil.28.26lt.3Bnum.26gt.3B.29" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.4.0/SearchReference/MathematicalFunctions#ceiling.28.26lt.3Bnum.26gt.3B.29_or_ceil.28.26lt.3Bnum.26gt.3B.29&lt;/A&gt;</description>
      <pubDate>Wed, 08 Jan 2025 21:32:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708303#M239539</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2025-01-08T21:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Convert duration time to number integer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708324#M239547</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/256438"&gt;@Miguel3393&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;at first, don't use the search command after the main search because your search is slower!&lt;/P&gt;&lt;P&gt;Then, you already calculated the difference in seconds in the field diffTime, you have only to add this field to the table command.&lt;/P&gt;&lt;P&gt;then, I'm not sure that the solution to extress the duration in minutes and seconds is correct, you shuld use:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Duracion=tostring(diffTime,"duration")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;In other words, please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="cdr" ("Call.TermParty.TrunkGroup.TrunkGroupId"="2811" OR
"Call.TermParty.TrunkGroup.TrunkGroupId"="2810") "Call.ConnectTime"=* "Call.DisconnectTime"=*
| lookup Pais Call.RoutingInfo.DestAddr OUTPUT Countrie
| eval Disctime=strftime('Call.DisconnectTime'/1000,"%m/%d/%Y %H:%M:%S %Q")
| eval Conntime=strftime('Call.ConnectTime'/1000, "%m/%d/%Y %H:%M:%S%Q")
| eval diffTime=('Call.DisconnectTime'-'Call.ConnectTime')
| eval Duracion=tostring(diffTime,"duration") 
| table Countrie Duracion diffTime&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 08:09:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708324#M239547</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-01-09T08:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Convert duration time to number integer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708360#M239560</link>
      <description>&lt;P&gt;Thanks for the response&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN class=""&gt;This is the result I get with what you mention.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Miguel3393_0-1736435619547.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/34085i65660AEA52953306/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Miguel3393_0-1736435619547.png" alt="Miguel3393_0-1736435619547.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 15:08:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708360#M239560</guid>
      <dc:creator>Miguel3393</dc:creator>
      <dc:date>2025-01-09T15:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: Convert duration time to number integer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708362#M239561</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/256438"&gt;@Miguel3393&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;let us know if we can help you more, or, please, accept one answer for the other people of Community.&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&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>Thu, 09 Jan 2025 15:09:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708362#M239561</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-01-09T15:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert duration time to number integer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708390#M239568</link>
      <description>&lt;P&gt;If you want to get duration as whole rounded up minutes, use ceil, as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/214410"&gt;@isoutamo&lt;/a&gt;&amp;nbsp;shows, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval WholeMinutes=ceil(diffTime/1000/60)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2025 00:47:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-duration-time-to-number-integer/m-p/708390#M239568</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-01-10T00:47:09Z</dc:date>
    </item>
  </channel>
</rss>

