<?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 edit my search to calculate the difference between two timestamps in the same event? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255518#M76511</link>
    <description>&lt;P&gt;The _time is already in epoch time (just shows as human readable form in search result/table), so no need to convert it. Updated the timeformat as well for UTC_EndTime.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ... my base search ...   | eval utc_endtime=strptime(UTC_EndTime,"%Y-%m-%dT%H:%M:%S.%N") | eval diff= _time-utc_endtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 11:23:30 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2020-09-29T11:23:30Z</dc:date>
    <item>
      <title>How to edit my search to calculate the difference between two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255515#M76508</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am trying to determine the &lt;STRONG&gt;time difference&lt;/STRONG&gt; between the two timeStamp columns in my events.&lt;BR /&gt;
I tried to use the search below, but cannot return anything for the "diff" at the end... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... my base search ... | eval raw_time=strptime(_time,'%Y-%m-%dT%H:%M:%S')  | eval utc_endtime=strptime(UTC_EndTime,'%Y-%m-%dT%H:%M:%S') | eval diff= raw_time-utc_endtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My example events are like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-10-15T03:59:59.999999, UTC_EndTime=2016-10-14T19:59:59.999999,
2016-10-15T02:59:59.999999, UTC_EndTime=2016-10-14T18:59:59.999999,
2016-10-15T01:59:59.999999, UTC_EndTime=2016-10-14T17:59:59.999999,
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would appreciate if you can help me to see the mistake I am doing here.&lt;/P&gt;

&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2016 23:28:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255515#M76508</guid>
      <dc:creator>pkurt</dc:creator>
      <dc:date>2016-10-14T23:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the difference between two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255516#M76509</link>
      <description>&lt;P&gt;Change single quotes &lt;CODE&gt;'&lt;/CODE&gt;  to double quotes &lt;CODE&gt;"&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval raw_time=strptime(_time,"%Y-%m-%dT%H:%M:%S")  | eval utc_endtime=strptime(UTC_EndTime,"%Y-%m-%dT%H:%M:%S") | eval diff= raw_time-utc_endtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Oct 2016 00:16:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255516#M76509</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-15T00:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the difference between two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255517#M76510</link>
      <description>&lt;P&gt;Use convert. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ... my base search ... | Convert mktime(_time) as raw_time timestamp="%Y-%m-%dT%H:%M:%S" | Convert mktime(UTC_EndTime) as utc_endtime "%Y-%m-%dT%H:%M:%S"| eval diff= raw_time-utc_endtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Oct 2016 01:48:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255517#M76510</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2016-10-15T01:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the difference between two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255518#M76511</link>
      <description>&lt;P&gt;The _time is already in epoch time (just shows as human readable form in search result/table), so no need to convert it. Updated the timeformat as well for UTC_EndTime.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ... my base search ...   | eval utc_endtime=strptime(UTC_EndTime,"%Y-%m-%dT%H:%M:%S.%N") | eval diff= _time-utc_endtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:23:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255518#M76511</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T11:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the difference between two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255519#M76512</link>
      <description>&lt;P&gt;it worked, thank you very much!&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 14:16:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255519#M76512</guid>
      <dc:creator>pkurt</dc:creator>
      <dc:date>2016-10-16T14:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the difference between two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255520#M76513</link>
      <description>&lt;P&gt;Thank you very much. Double quotes are not the issue. It works only if I add ".%N" to my time string since the actual timeStamp has ".999999" component. &lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 17:51:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255520#M76513</guid>
      <dc:creator>pkurt</dc:creator>
      <dc:date>2016-10-18T17:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the difference between two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255521#M76514</link>
      <description>&lt;P&gt;I could not make this work. Thank you very much though!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 17:58:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-difference-between-two/m-p/255521#M76514</guid>
      <dc:creator>pkurt</dc:creator>
      <dc:date>2016-10-18T17:58:04Z</dc:date>
    </item>
  </channel>
</rss>

