<?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 How do I do mathematical operations (subtraction) with two timestamps in the same event? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177812#M35639</link>
    <description>&lt;P&gt;I've been trying to: &lt;BR /&gt;
1) convert two date stamps into epoch  (timestamp and lastmodified).  The lastmodified stamp will be more recent.&lt;BR /&gt;
2) calculate if there is greater than a 7 day difference between the two&lt;BR /&gt;
3) then display these events.  &lt;/P&gt;

&lt;P&gt;My time stamps are all in the %d/%m/%Y %H:%M:%S format.&lt;/P&gt;

&lt;P&gt;index=netcool_daily name="Auto Ticket" | eval starttime=strptime(timestamp,"%m/%d/%Y %H:%M:%S") | eval endtime=strptime(lastmodified,"%m/%d/%Y %H:%M:%S") | eval difference=(endtime - starttime)/86400 | search difference &amp;gt; 7&lt;/P&gt;

&lt;P&gt;I get nothing returned.&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jun 2015 13:27:45 GMT</pubDate>
    <dc:creator>hmdoan</dc:creator>
    <dc:date>2015-06-26T13:27:45Z</dc:date>
    <item>
      <title>How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177812#M35639</link>
      <description>&lt;P&gt;I've been trying to: &lt;BR /&gt;
1) convert two date stamps into epoch  (timestamp and lastmodified).  The lastmodified stamp will be more recent.&lt;BR /&gt;
2) calculate if there is greater than a 7 day difference between the two&lt;BR /&gt;
3) then display these events.  &lt;/P&gt;

&lt;P&gt;My time stamps are all in the %d/%m/%Y %H:%M:%S format.&lt;/P&gt;

&lt;P&gt;index=netcool_daily name="Auto Ticket" | eval starttime=strptime(timestamp,"%m/%d/%Y %H:%M:%S") | eval endtime=strptime(lastmodified,"%m/%d/%Y %H:%M:%S") | eval difference=(endtime - starttime)/86400 | search difference &amp;gt; 7&lt;/P&gt;

&lt;P&gt;I get nothing returned.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 13:27:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177812#M35639</guid>
      <dc:creator>hmdoan</dc:creator>
      <dc:date>2015-06-26T13:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177813#M35640</link>
      <description>&lt;P&gt;You say your timestamps are in "d/m/Y" format, but your strptime commands are using "m/d/Y" format.  Which is the correct format?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 14:46:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177813#M35640</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-06-26T14:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177814#M35641</link>
      <description>&lt;P&gt;Everything looks OK so the problem has to be that either (or both) &lt;CODE&gt;starttime&lt;/CODE&gt; or &lt;CODE&gt;endtime&lt;/CODE&gt; is not created and that is surely because either &lt;CODE&gt;timestamp&lt;/CODE&gt; or &lt;CODE&gt;lastmodified&lt;/CODE&gt; does not exist.  Try this search and whichever field does not exist, make it exists (probably just fix a typo):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=netcool_daily name="Auto Ticket" | eval starttime=strptime(timestamp,"%m/%d/%Y %H:%M:%S") | eval endtime=strptime(lastmodified,"%m/%d/%Y %H:%M:%S") | table timestamp lastmodified starttime endtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jun 2015 14:49:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177814#M35641</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-26T14:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177815#M35642</link>
      <description>&lt;P&gt;Sorry.  The format is Year/Month/Day H:M:S&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 16:27:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177815#M35642</guid>
      <dc:creator>hmdoan</dc:creator>
      <dc:date>2015-06-26T16:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177816#M35643</link>
      <description>&lt;P&gt;My stupid error:&lt;/P&gt;

&lt;P&gt;The format is in "%Y/%m/%d %H:%M:%S"&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 16:28:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177816#M35643</guid>
      <dc:creator>hmdoan</dc:creator>
      <dc:date>2015-06-26T16:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177817#M35644</link>
      <description>&lt;P&gt;So when you change your strptime commands to &lt;CODE&gt;strptime(timestamp, "%Y/%m/%d %H:%M:%S")&lt;/CODE&gt; and &lt;CODE&gt;strptime(lastmodified, "%Y/%m/%d %H:%M:%S")&lt;/CODE&gt; does it work?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 16:47:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177817#M35644</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-06-26T16:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177818#M35645</link>
      <description>&lt;P&gt;So when you change your strptime commands to &lt;CODE&gt;strptime(timestamp, "%Y/%m/%d %H:%M:%S")&lt;/CODE&gt; and &lt;CODE&gt;strptime(lastmodified, "%Y/%m/%d %H:%M:%S")&lt;/CODE&gt; does it work?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 16:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177818#M35645</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-06-26T16:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177819#M35646</link>
      <description>&lt;P&gt;So when you change your strptime commands to &lt;CODE&gt;strptime(timestamp, "%Y/%m/%d %H:%M:%S")&lt;/CODE&gt; and &lt;CODE&gt;strptime(lastmodified, "%Y/%m/%d %H:%M:%S")&lt;/CODE&gt; does it work?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 16:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177819#M35646</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-06-26T16:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177820#M35647</link>
      <description>&lt;P&gt;You say your timestamps are in "d/m/Y" format, but your strptime commands are using "m/d/Y" format.  Which is the correct format?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 16:55:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177820#M35647</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-06-26T16:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177821#M35648</link>
      <description>&lt;P&gt;Thanks!  That was it.  I had the wrong date format.  Once I fixed that, the search worked great.  Typo on my part.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 16:55:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177821#M35648</guid>
      <dc:creator>hmdoan</dc:creator>
      <dc:date>2015-06-26T16:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do mathematical operations (subtraction) with two timestamps in the same event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177822#M35649</link>
      <description>&lt;P&gt;Yes - once i changed my time formatting to be consistent, it worked.  The dangers of cut-n-paste!!!  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2015 21:57:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-do-mathematical-operations-subtraction-with-two/m-p/177822#M35649</guid>
      <dc:creator>hmdoan</dc:creator>
      <dc:date>2015-06-30T21:57:54Z</dc:date>
    </item>
  </channel>
</rss>

