<?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: Calcuate time differences in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310836#M58413</link>
    <description>&lt;P&gt;what's the difference between %3N and %3Q?&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2017 14:48:59 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-04-05T14:48:59Z</dc:date>
    <item>
      <title>Calcuate time differences</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310833#M58410</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Looking out to calculate and find out the time differences between two time stamps (milliseconds and seconds). Please help.&lt;BR /&gt;
B_Timestamp Minus A_Timestamp (Need to achieve this logic).&lt;/P&gt;

&lt;P&gt;A_Timestamp                              B_Timestamp                     epoc_ATimestamp    epoc_BTimestamp&lt;BR /&gt;
2017-03-09-11:59:59.799     2017-03-09-11:59:59.817     1488978000.000000   1488978000.000000&lt;BR /&gt;
2017-03-09-11:59:59.722     2017-03-09-11:59:59.754     1488978000.000000   1488978000.000000&lt;/P&gt;

&lt;P&gt;index="idx_sample" | eval DateTime = split(DateTime," ") | eval A_Timestamp = mvindex(DateTime,0) | eval B_Timestamp = mvindex(DateTime,1) |      eval epoc_ATimestamp=strptime(A_Timestamp,"%Y-%m-%d")  |  eval epoc_BTimestamp=strptime(B_Timestamp,"%Y-%m-%d")  |     table A_Timestamp,B_Timestamp,epoc_ATimestamp,epoc_BTimestamp&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:32:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310833#M58410</guid>
      <dc:creator>splunklakshman</dc:creator>
      <dc:date>2020-09-29T13:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calcuate time differences</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310834#M58411</link>
      <description>&lt;P&gt;Try like this (time format updated).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="idx_sample" | eval DateTime = split(DateTime," ") | eval A_Timestamp = mvindex(DateTime,0) | eval B_Timestamp = mvindex(DateTime,1) | eval epoc_ATimestamp=strptime(A_Timestamp,"%Y-%m-%d-%H:%M:%S.%3N") | eval epoc_BTimestamp=strptime(B_Timestamp,"%Y-%m-%d-%H:%M:%S.%3N") | table A_Timestamp,B_Timestamp,epoc_ATimestamp,epoc_BTimestamp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See this for more information on time formats&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.5.2/SearchReference/Commontimeformatvariables"&gt;https://docs.splunk.com/Documentation/Splunk/6.5.2/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 14:46:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310834#M58411</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-05T14:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calcuate time differences</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310835#M58412</link>
      <description>&lt;P&gt;The easiest way is to translate them both into epoch time, which is in seconds already.  (Your Epoch timestamps are incorrect.)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval epoc_ATimestamp=strptime(A_Timestamp,"%Y-%m-%d-%H:%M:%S.%3Q") 
 | eval epoc_BTimestamp=strptime(B_Timestamp,"%Y-%m-%d-%H:%M:%S.%3Q") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;note - %3Q, %3N or %Q will all work to extract the 3-digit millisecond data.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 14:46:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310835#M58412</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-05T14:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calcuate time differences</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310836#M58413</link>
      <description>&lt;P&gt;what's the difference between %3N and %3Q?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 14:48:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310836#M58413</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-05T14:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calcuate time differences</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310837#M58414</link>
      <description>&lt;P&gt;Both will be same if a width is specified. I believe in strptime both %N and %Q behave the same. There is a great explanation for this difference in the comments section of the link that I shared.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 15:01:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310837#M58414</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-05T15:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calcuate time differences</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310838#M58415</link>
      <description>&lt;P&gt;Thanks, I initially called out %3Q, then assumed yours was right when i couldn't distinguish them in the docs.  I'll change mine back.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 15:39:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/310838#M58415</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-05T15:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calcuate time differences</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/523853#M88456</link>
      <description>&lt;P&gt;Since the comment section mentioned in this answer is gone from docs but this thread comes up first when googling for splunk strptime %Q %N (at least for me), I'll add a link to a different place where I found an explanation by &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/203121"&gt;@DalJeanis&lt;/a&gt;&amp;nbsp;:&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/How-can-I-find-the-time-duration-between-two-fields/m-p/372494/highlight/true#M109556" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Search/How-can-I-find-the-time-duration-between-two-fields/m-p/372494/highlight/true#M109556&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Basically, %N and %Q can do the same if you provide them with a length (such as %6N or %3N). Without length specified, %N will default to three and %Q to six digits.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 06:23:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calcuate-time-differences/m-p/523853#M88456</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2020-10-09T06:23:13Z</dc:date>
    </item>
  </channel>
</rss>

