<?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: Why am I unable to find the time difference between two dates with my current eval statements? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252703#M75619</link>
    <description>&lt;P&gt;strftime is a string format. You need to change to epoch time or a number to do math. So try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval onlydate=strptime(date1,"%-m/%d/%y %H:%M") | eval datediff=tostring(now() - onlydate, "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 17 May 2016 22:24:48 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-05-17T22:24:48Z</dc:date>
    <item>
      <title>Why am I unable to find the time difference between two dates with my current eval statements?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252702#M75618</link>
      <description>&lt;P&gt;Hi all.&lt;/P&gt;

&lt;P&gt;I have one field called &lt;STRONG&gt;date1&lt;/STRONG&gt; with a timestamp like this: &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;5/7/16 16:35&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I need the time difference (just for the date) in days against &lt;CODE&gt;now()&lt;/CODE&gt;. I am using this expression:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...  | eval onlydate=strftime(strptime(date1,"%-m/%d/%y %H:%M"),"%-m/%-d/%y") | eval nowstring=strftime(now(), "%-m/%-d/%y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And works well, but I can't calculate the time difference between &lt;STRONG&gt;nowstring&lt;/STRONG&gt; and &lt;STRONG&gt;onlydate&lt;/STRONG&gt; and both are in the same format. Any clue? I tried using &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval difference=(nowstring - onlydate)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And didn't work.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 22:05:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252702#M75618</guid>
      <dc:creator>changux</dc:creator>
      <dc:date>2016-05-17T22:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I unable to find the time difference between two dates with my current eval statements?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252703#M75619</link>
      <description>&lt;P&gt;strftime is a string format. You need to change to epoch time or a number to do math. So try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval onlydate=strptime(date1,"%-m/%d/%y %H:%M") | eval datediff=tostring(now() - onlydate, "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 May 2016 22:24:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252703#M75619</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-17T22:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I unable to find the time difference between two dates with my current eval statements?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252704#M75620</link>
      <description>&lt;P&gt;Great, thanks. Datediff result is in epoch, how i can convert to human? i tried with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;. | eval formatted_time=strftime(datediff/1000, "%H:%M:%S %d-%m-%Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Without luck.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 01:50:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252704#M75620</guid>
      <dc:creator>changux</dc:creator>
      <dc:date>2016-05-18T01:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I unable to find the time difference between two dates with my current eval statements?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252705#M75621</link>
      <description>&lt;P&gt;My datediff field has values like 6+08:19:34.000000.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 01:58:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252705#M75621</guid>
      <dc:creator>changux</dc:creator>
      <dc:date>2016-05-18T01:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I unable to find the time difference between two dates with my current eval statements?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252706#M75622</link>
      <description>&lt;P&gt;Something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|eval formatted_time=strftime(datediff,"%F %T")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should do the trick.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 09:52:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252706#M75622</guid>
      <dc:creator>sheamus69</dc:creator>
      <dc:date>2016-05-18T09:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I unable to find the time difference between two dates with my current eval statements?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252707#M75623</link>
      <description>&lt;P&gt;datediff is in seconds. duration format is days+hours:mins:seconds.microseconds. what format are you looking for?&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 15:55:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252707#M75623</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-18T15:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I unable to find the time difference between two dates with my current eval statements?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252708#M75624</link>
      <description>&lt;P&gt;You could do something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval onlydate=strptime(date1,"%-m/%d/%y %H:%M") | eval datediff=tostring(round(now() - onlydate, 0), "duration") | eval datediff= replace(datediff,"(\d*)\+?(\d+)\:(\d+)\:(\d+)","\1d \2h \3min \4s")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 16:04:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252708#M75624</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-18T16:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I unable to find the time difference between two dates with my current eval statements?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252709#M75625</link>
      <description>&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 20:15:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-find-the-time-difference-between-two-dates/m-p/252709#M75625</guid>
      <dc:creator>changux</dc:creator>
      <dc:date>2016-05-18T20:15:00Z</dc:date>
    </item>
  </channel>
</rss>

