<?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 eval Time difference in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/eval-Time-difference/m-p/109208#M28472</link>
    <description>&lt;P&gt;I have the following data indexed:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;initialTime     Purchase_Time
2011-11-04T13:17Z   2011-11-04 09:18:20
2011-11-04T21:08Z   2011-11-04 14:08:28
2011-11-04T15:16Z   2011-11-04 16:38:16
2011-11-04T15:15Z   2011-11-04 10:18:12
2011-11-04T21:25Z   2011-11-04 14:26:40
2011-11-04T13:35Z   2011-11-04 09:36:45
2011-11-04T20:01Z   2011-11-04 16:03:02
2011-11-04T19:31Z   2011-11-04 20:28:55
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to get the following result set with a splunk query:&lt;/P&gt;

&lt;P&gt;|eval Time_Diff = initialTime - Purchase_Time&lt;/P&gt;

&lt;P&gt;But I have not been able to...&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 10:07:05 GMT</pubDate>
    <dc:creator>lpolo</dc:creator>
    <dc:date>2020-09-28T10:07:05Z</dc:date>
    <item>
      <title>eval Time difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-Time-difference/m-p/109208#M28472</link>
      <description>&lt;P&gt;I have the following data indexed:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;initialTime     Purchase_Time
2011-11-04T13:17Z   2011-11-04 09:18:20
2011-11-04T21:08Z   2011-11-04 14:08:28
2011-11-04T15:16Z   2011-11-04 16:38:16
2011-11-04T15:15Z   2011-11-04 10:18:12
2011-11-04T21:25Z   2011-11-04 14:26:40
2011-11-04T13:35Z   2011-11-04 09:36:45
2011-11-04T20:01Z   2011-11-04 16:03:02
2011-11-04T19:31Z   2011-11-04 20:28:55
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to get the following result set with a splunk query:&lt;/P&gt;

&lt;P&gt;|eval Time_Diff = initialTime - Purchase_Time&lt;/P&gt;

&lt;P&gt;But I have not been able to...&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:07:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-Time-difference/m-p/109208#M28472</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2020-09-28T10:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: eval Time difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-Time-difference/m-p/109209#M28473</link>
      <description>&lt;P&gt;This should give you the difference in seconds.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval itime=strptime(initialTime,"%Y-%m-%dT%H:%M") | eval ptime=strptime(PurchaseTime,"%Y-%m-%d %H:%M:%S") | eval TimeDiff=itime-ptime  | table initialTime PurchaseTime TimeDiff
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Nov 2011 21:39:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-Time-difference/m-p/109209#M28473</guid>
      <dc:creator>eelisio2</dc:creator>
      <dc:date>2011-11-16T21:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: eval Time difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-Time-difference/m-p/109210#M28474</link>
      <description>&lt;P&gt;Ipolo, the reason this works where your initial approach didn't is because the example field values from your search are just strings.  Splunk doesn't know how to subtract them and make sense of them.  What eelisio is doing is converting the timestamp strings to &lt;CODE&gt;time_t&lt;/CODE&gt; values (that is, the number of seconds since 1/1/1970 00:00:00 UTC).  The &lt;CODE&gt;time_t&lt;/CODE&gt; format (sometimes called epoch time) is really awesome because you can store large time ranges in simple 32-bit values, and because you can easily figure out the delta between any two timestamps via addition/subtraction.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2011 04:31:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-Time-difference/m-p/109210#M28474</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-11-17T04:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: eval Time difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-Time-difference/m-p/109211#M28475</link>
      <description>&lt;P&gt;Splunk (by default) parses out the first timestamp it sees from an event (well, it could be a different timestamp if you configure it this way) and stores it in &lt;CODE&gt;time_t&lt;/CODE&gt; format as the field &lt;CODE&gt;_time&lt;/CODE&gt;.  But, it does not do this by default with any additional timestamp-looking data within the event.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2011 04:33:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-Time-difference/m-p/109211#M28475</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-11-17T04:33:00Z</dc:date>
    </item>
  </channel>
</rss>

