<?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: How  to get the time difference of two timestamp in minutes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651410#M225210</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232766"&gt;@mikeyty07&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;yes, it's possible, please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt; 
| rex "received_time\"\:(?&amp;lt;recTime&amp;gt;[^\,]+)" 
| eval diff = recTime - _time 
| eval recTime = strftime(recTime/1000, "%Y-%m-%d %H:%M:%S.%3N")
| eval diff=tostring(diff,"duration")
| table recTime _time  diff&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jul 2023 05:52:23 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-07-21T05:52:23Z</dc:date>
    <item>
      <title>How  to get the time difference of two timestamp in minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651346#M225187</link>
      <description>&lt;P&gt;I 've&amp;nbsp; two fields one is &lt;STRONG&gt;_time&lt;/STRONG&gt; and another one is &lt;STRONG&gt;received_time.&amp;nbsp;&lt;/STRONG&gt; I want to get the time differences between these two timestamp.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Logs look like&amp;nbsp;&lt;BR /&gt;2023-07-11 11:19:24.964 .....&amp;nbsp;received_time= 1688574223791&lt;/P&gt;
&lt;P&gt;I converted the epoch to human readable but i couldnt get the time differences&amp;nbsp; between these two timestamp.&lt;/P&gt;
&lt;P&gt;my search:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;query&amp;gt; | rex "received_time\"\:(?&amp;lt;recTime&amp;gt;[^\,]+)" | eval recTime = strftime(recTime/1000, "%Y-%m-%d %H:%M:%S.%3N")
| eval diff = recTime - _time 
| table recTime _time  diff&lt;/LI-CODE&gt;
&lt;P&gt;but it doesnt show any data on diff. Am I missing something?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 16:53:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651346#M225187</guid>
      <dc:creator>mikeyty07</dc:creator>
      <dc:date>2023-07-20T16:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: How  to get the time difference of two timestamp in minutes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651347#M225188</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232766"&gt;@mikeyty07&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can calculate diff before tranforming timestamps from epoch to human readable.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt; 
| rex "received_time\"\:(?&amp;lt;recTime&amp;gt;[^\,]+)" 
| eval diff = recTime - _time 
| eval recTime = strftime(recTime/1000, "%Y-%m-%d %H:%M:%S.%3N")
| table recTime _time  diff&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 16:45:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651347#M225188</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-07-20T16:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: How  to get the time difference of two timestamp in minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651357#M225190</link>
      <description>&lt;P&gt;If you extract your recTime as a string from the raw event you have to either parse it into a numerical timestamp with strptime() or at least (if it's already in epoch) cast it to integer by using tonumber().&lt;/P&gt;&lt;P&gt;EDIT: OK. I just noticed that in your raw data timestamp is already numerical. So you need to do&lt;/P&gt;&lt;PRE&gt;| eval diff = tonum(recTime)/1000 - _time&lt;/PRE&gt;&lt;P&gt;Also - when you're manipulating time, it's often more convenient to use fieldformat instead of eval to produce human-readable time strings. But if you insist on rendering timestamp to string with eval, do it &lt;U&gt;after&lt;/U&gt; you calculate the diff part.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 17:10:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651357#M225190</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-07-20T17:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: How  to get the time difference of two timestamp in minutes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651377#M225197</link>
      <description>&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;_time&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;recTime&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;diff&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;2023-07-11 11:12:44.888&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;2023-07-11 11:15:55.999&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;0 00:03:11.111&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;the diff is coming in numerical can it be done like this table?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 19:35:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651377#M225197</guid>
      <dc:creator>mikeyty07</dc:creator>
      <dc:date>2023-07-20T19:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: How  to get the time difference of two timestamp in minutes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651410#M225210</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232766"&gt;@mikeyty07&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;yes, it's possible, please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt; 
| rex "received_time\"\:(?&amp;lt;recTime&amp;gt;[^\,]+)" 
| eval diff = recTime - _time 
| eval recTime = strftime(recTime/1000, "%Y-%m-%d %H:%M:%S.%3N")
| eval diff=tostring(diff,"duration")
| table recTime _time  diff&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 05:52:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651410#M225210</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-07-21T05:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: How  to get the time difference of two timestamp in minutes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651463#M225222</link>
      <description>&lt;P&gt;Sure. Since _time is being internally stored as a number of seconds, all arithmetics involving this number will yield number of seconds. There are several functions allowing you to convert it to more human-friendly format.&lt;/P&gt;&lt;P&gt;Of course you could calculate it manually, but you can use - as &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt; already showed - the convert() function. I would however use fieldformat instead of eval to keep the value internally as a number (which makes it easier to do subsequent manipulations if you need it or sorting).&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 11:25:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/651463#M225222</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-07-21T11:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: How  to get the time difference of two timestamp in minutes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/652396#M225492</link>
      <description>&lt;P class="lia-align-justify"&gt;this gave me the idea to change time to numeric and from there strftime and do calculate the time diff&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 16:16:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/652396#M225492</guid>
      <dc:creator>mikeyty07</dc:creator>
      <dc:date>2023-07-28T16:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: How  to get the time difference of two timestamp in minutes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/652431#M225501</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232766"&gt;@mikeyty07&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&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>Sat, 29 Jul 2023 05:05:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-difference-of-two-timestamp-in-minutes/m-p/652431#M225501</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-07-29T05:05:14Z</dc:date>
    </item>
  </channel>
</rss>

