<?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: convert milli seconds into duration format HH:MM:SS in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627204#M217946</link>
    <description>&lt;P&gt;Hey I did try your approach. It was great&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But there was one problem here, the time was 4333403 ms which when converted to HH:MM:SS should be around 1hr&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the query gave me it as 3hrs&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="sjs_2-1673846949095.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/23393i8CB015A847C54B4C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sjs_2-1673846949095.png" alt="sjs_2-1673846949095.png" /&gt;&lt;/span&gt;&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="sjs_0-1673846895984.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/23391iA01428687D1838E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sjs_0-1673846895984.png" alt="sjs_0-1673846895984.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jan 2023 05:30:20 GMT</pubDate>
    <dc:creator>sjs</dc:creator>
    <dc:date>2023-01-16T05:30:20Z</dc:date>
    <item>
      <title>How to convert milli seconds into duration format HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627013#M217915</link>
      <description>&lt;P&gt;Hey people, I am trying to convert the execution time which I get in ms to duration format&lt;/P&gt;
&lt;P&gt;| rex "EXECUTION_TIME : (?&amp;lt;totalTime&amp;gt;[^ms]+)"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did also try something like this&lt;/P&gt;
&lt;PRE&gt;| eval inSec = inMs / 1000 | fieldformat inSec = tostring(inSec, "duration")&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but it is giving me null value&lt;/P&gt;
&lt;P&gt;Could you please help me out here&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 17:36:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627013#M217915</guid>
      <dc:creator>sjs</dc:creator>
      <dc:date>2023-01-13T17:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: convert milli seconds into duration format HH:MM:SS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627017#M217916</link>
      <description>&lt;P&gt;Rex will give you a string value. You can't divide a string value or convert it to duration. Convert it number with tonumber() first.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 06:17:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627017#M217916</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-01-13T06:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: convert milli seconds into duration format HH:MM:SS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627044#M217923</link>
      <description>&lt;P&gt;Your title says you want to convert some data originally in miliseconds into a different format. &amp;nbsp;But you didn't illustrate your data, either the original data, or intermediate data, namely &lt;EM&gt;totalTime&lt;/EM&gt; that you used rex to extract. &amp;nbsp; Nor did you explain how the field &lt;EM&gt;inMs&lt;/EM&gt; in the tried code relates to totalTime.&lt;/P&gt;&lt;P&gt;I have several suspicions. &amp;nbsp;First is the rex. &amp;nbsp;Unless your raw data has some really funky characteristics, the extraction group would be something like &lt;FONT face="andale mono,times"&gt;(?&amp;lt;totalTime&amp;gt;\d+)&lt;/FONT&gt; (all integers) or &lt;FONT face="andale mono,times"&gt;(?&amp;lt;totalTime&amp;gt;[\d\.]+)&amp;nbsp;&lt;/FONT&gt;(decimals). &amp;nbsp;Have you confirmed that totalTime is a numeric value?&lt;/P&gt;&lt;P&gt;If totalTime is a valid numeric field, you can use&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/DateandTimeFunctions#strftime.28X.2CY.29" target="_blank" rel="noopener"&gt;strftime&lt;/A&gt;&amp;nbsp;to reformat it into HH::MM::SS.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fieldformat totalTime = strftime(totalTime, "%H:%M:%S")&lt;/LI-CODE&gt;&lt;P&gt;As expected, if totalTime exceeds 24 hours, the reformatted representation will cross 0.&lt;/P&gt;&lt;P&gt;Example,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval totalTime = 12345.6789
| fieldformat totalTime = strftime(totalTime, "%H:%M:%S")&lt;/LI-CODE&gt;&lt;P&gt;results in&lt;/P&gt;&lt;TABLE border="1" width="4.826675849403123%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="21.969696969696972%" height="30px"&gt;totalTime&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="21.969696969696972%" height="25px"&gt;&lt;SPAN&gt;19:25:45&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;whereas&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval totalTime = 123456.789
| fieldformat totalTime = strftime(totalTime, "%H:%M:%S")&lt;/LI-CODE&gt;&lt;P&gt;gives&lt;/P&gt;&lt;TABLE border="1" width="4.607310478522599%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="21.464646464646464%"&gt;totalTime&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="21.464646464646464%"&gt;&lt;SPAN&gt;02:17:36&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 13 Jan 2023 09:14:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627044#M217923</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-01-13T09:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: convert milli seconds into duration format HH:MM:SS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627204#M217946</link>
      <description>&lt;P&gt;Hey I did try your approach. It was great&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But there was one problem here, the time was 4333403 ms which when converted to HH:MM:SS should be around 1hr&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the query gave me it as 3hrs&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="sjs_2-1673846949095.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/23393i8CB015A847C54B4C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sjs_2-1673846949095.png" alt="sjs_2-1673846949095.png" /&gt;&lt;/span&gt;&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="sjs_0-1673846895984.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/23391iA01428687D1838E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sjs_0-1673846895984.png" alt="sjs_0-1673846895984.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 05:30:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627204#M217946</guid>
      <dc:creator>sjs</dc:creator>
      <dc:date>2023-01-16T05:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: convert milli seconds into duration format HH:MM:SS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627209#M217948</link>
      <description>&lt;P&gt;You need to convert ms to s (by dividing by 1000) before using in strftime&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval dob_write_execution_time = strftime(DOB_WRITE_EXECUTION_TIME/1000, "%H:%M:%S")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 16 Jan 2023 07:22:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627209#M217948</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-16T07:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: convert milli seconds into duration format HH:MM:SS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627403#M218022</link>
      <description>&lt;P&gt;In addition to&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;'s diagnosis that I missed "milli" in millisecond, there's a separate caveat (which should not show on most search heads but...): locale. &amp;nbsp;It turns out that Splunk is "too good" at handling timezone that strftime is calculated based on the search head's local time. &amp;nbsp;As a result, the above formula can give you very funny results if search head is not on UTC. &amp;nbsp;Whereas most search heads are better off using UTC, there is no guarantee. &amp;nbsp;I searched in vain to find a reverse function of convert dur2sec(). &amp;nbsp;So, I came up with a really dumb way to brute force output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval offset = strftime(0, "%::z")
| rex field=offset "^(?&amp;lt;sign&amp;gt;[+-])(?&amp;lt;offset&amp;gt;[\d:]+)$"
| eval offset = sign . strptime(offset, "%H:%M:%S")
| fieldformat string_DDB_WRITE_EXECUTIION_TIME = strftime(DDB_WRITE_EXECUTION_TIME/1000 + offset, "%H:%M:%S")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using your sample data of&amp;nbsp;4333403ms and my local timezone of -0800, the output is&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;DDB_WRITE_EXECUTION_TIME&lt;/TD&gt;&lt;TD&gt;offset&lt;/TD&gt;&lt;TD&gt;sign&lt;/TD&gt;&lt;TD&gt;string_DDB_WRITE_EXECUTIION_TIME&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4333403&lt;/TD&gt;&lt;TD&gt;-1673971200.000000&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;01:12:13&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 18 Jan 2023 00:46:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627403#M218022</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-01-18T00:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: convert milli seconds into duration format HH:MM:SS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627417#M218024</link>
      <description>&lt;P&gt;Thanks this helped&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 04:47:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627417#M218024</guid>
      <dc:creator>sjs</dc:creator>
      <dc:date>2023-01-18T04:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert milli seconds into duration format HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627419#M218025</link>
      <description>&lt;P&gt;I have an another question, lets have I have table as such&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which I generated with this command&lt;/P&gt;&lt;P&gt;.. |&amp;nbsp;DDB_WRITE_EXECUTION_TIME="*" FILTERING_EXECUTION_TIME="*" | transpose 0&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="sjs_0-1674019534898.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/23412iB50F06ED0B6DB809/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sjs_0-1674019534898.png" alt="sjs_0-1674019534898.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;is it possible for me to convert all the values of row1 to HH:MM:SS format&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 05:27:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627419#M218025</guid>
      <dc:creator>sjs</dc:creator>
      <dc:date>2023-01-18T05:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert milli seconds into duration format HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627422#M218026</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/252815"&gt;@sjs&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can use below eval;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval row1=tostring(row1,"duration")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 06:21:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627422#M218026</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2023-01-18T06:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert milli seconds into duration format HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627520#M218052</link>
      <description>&lt;P&gt;Yes. &amp;nbsp;Replace fieldformat with eval. (Use fieldformat allows you to manipulate time numerically while displaying it in a readable format. &amp;nbsp;But if you want it as column head, which is for displaying purposes, you must convert it to a real string. &amp;nbsp;eval will do that.)&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 20:28:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-milli-seconds-into-duration-format-HH-MM-SS/m-p/627520#M218052</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-01-18T20:28:52Z</dc:date>
    </item>
  </channel>
</rss>

