<?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: Strftime and adding leading zeros to time difference in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555706#M92030</link>
    <description>&lt;P&gt;I just ran a test and did this to see how formatting would be for a day or more time difference.&lt;/P&gt;&lt;P&gt;| eval time_diff=(1623704985-new_mdctime).&amp;nbsp; &amp;nbsp; (the # is&lt;SPAN&gt;&amp;nbsp;June 14, 2021 9:09:45 PM)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;against this date:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2021-06-11T21:48:28.254Z&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Which has a strptime of1623462508.254000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I get a difference of:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;242476.746000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any idea how to get it formatted properly so it shows hours, minutes, seconds and milliseconds?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Jun 2021 01:22:24 GMT</pubDate>
    <dc:creator>timm7474</dc:creator>
    <dc:date>2021-06-15T01:22:24Z</dc:date>
    <item>
      <title>Strftime and adding leading zeros to time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555693#M92020</link>
      <description>&lt;P&gt;Hi, I have a field called time_diff that I've eval'd from two other fields to calculate the difference in time between those fields.&amp;nbsp; The calculation is working fine and when I strftime the time_diff back to human readable, I'm using&amp;nbsp;&lt;/P&gt;&lt;P&gt;eval time_diff_final=strftime(time_diff, "%H:%M:%S.%3Q")&lt;/P&gt;&lt;P&gt;When I display the result of time_diff I see&lt;/P&gt;&lt;P&gt;0.13400&lt;/P&gt;&lt;P&gt;However when I look at the result of time_diff_final I see this.&lt;/P&gt;&lt;P&gt;19:00:00.134&lt;/P&gt;&lt;P&gt;The milliseconds is the correct calculation, but for some reason instead of putting a zero in the %H field I'm getting 19 for every single result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 21:31:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555693#M92020</guid>
      <dc:creator>timm7474</dc:creator>
      <dc:date>2021-06-14T21:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Strftime and adding leading zeros to time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555696#M92021</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/230323"&gt;@timm7474&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How did you calculate time_diff can you share the samples of it?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 23:43:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555696#M92021</guid>
      <dc:creator>venkatasri</dc:creator>
      <dc:date>2021-06-14T23:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Strftime and adding leading zeros to time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555698#M92023</link>
      <description>&lt;P&gt;Sure, here is that part of the SPL.&lt;/P&gt;&lt;P&gt;| eval new_attimestamp=strptime('@timestamp',"%Y-%m-%dT%H:%M:%S.%3Q")&lt;BR /&gt;| eval new_mdctime=strptime('mdc.time',"%Y-%m-%dT%H:%M:%S.%3Q")&lt;BR /&gt;| eval time_diff=(new_attimestamp-new_mdctime)&lt;BR /&gt;| eval time_diff_final=strftime(time_diff,"%H:%M:%S.%3")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 23:48:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555698#M92023</guid>
      <dc:creator>timm7474</dc:creator>
      <dc:date>2021-06-14T23:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Strftime and adding leading zeros to time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555700#M92024</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/230323"&gt;@timm7474&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you share few samples of time_diff?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 00:06:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555700#M92024</guid>
      <dc:creator>venkatasri</dc:creator>
      <dc:date>2021-06-15T00:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Strftime and adding leading zeros to time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555701#M92025</link>
      <description>&lt;P&gt;&lt;SPAN&gt;0.114000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0.011000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;and time_diff_final looks like this for the above values.&amp;nbsp; And you can see the 19 added when I add hour %H.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;19:00:00.114&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;19:00:00.011&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 00:12:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555701#M92025</guid>
      <dc:creator>timm7474</dc:creator>
      <dc:date>2021-06-15T00:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Strftime and adding leading zeros to time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555702#M92026</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/230323"&gt;@timm7474&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are actually getting duration in seconds as outcome not epoc, strftime function accepts epoc and returns as per format. your time_diff is difference in seconds.&lt;/P&gt;&lt;P&gt;-----&lt;/P&gt;&lt;P&gt;An upvote would be appreciated if it helps!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 00:27:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555702#M92026</guid>
      <dc:creator>venkatasri</dc:creator>
      <dc:date>2021-06-15T00:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Strftime and adding leading zeros to time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555706#M92030</link>
      <description>&lt;P&gt;I just ran a test and did this to see how formatting would be for a day or more time difference.&lt;/P&gt;&lt;P&gt;| eval time_diff=(1623704985-new_mdctime).&amp;nbsp; &amp;nbsp; (the # is&lt;SPAN&gt;&amp;nbsp;June 14, 2021 9:09:45 PM)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;against this date:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2021-06-11T21:48:28.254Z&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Which has a strptime of1623462508.254000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I get a difference of:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;242476.746000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any idea how to get it formatted properly so it shows hours, minutes, seconds and milliseconds?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 01:22:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555706#M92030</guid>
      <dc:creator>timm7474</dc:creator>
      <dc:date>2021-06-15T01:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: Strftime and adding leading zeros to time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555711#M92034</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/230323"&gt;@timm7474&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This might work but need through testing, a good way to start!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval time_diff=242476.746000
| eval n=time_diff/3600 
| eval m=(n-floor(n))*60, s=round((m-floor(m))*60,3), mf=if(m &amp;gt; 1, floor(m), 0), h=floor(n)
| eval TIME_DIFF=h.":".mf.":".s&lt;/LI-CODE&gt;&lt;P&gt;Output TIME_DIFF =&amp;nbsp;&lt;SPAN&gt;67:21:16.746 ,&amp;nbsp; h:m:s.3Q format&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;---&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;An upvote would be appreciated if it helps!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 02:54:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Strftime-and-adding-leading-zeros-to-time-difference/m-p/555711#M92034</guid>
      <dc:creator>venkatasri</dc:creator>
      <dc:date>2021-06-15T02:54:23Z</dc:date>
    </item>
  </channel>
</rss>

