<?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: Compare/calculate with current date in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Compare-calculate-with-current-date/m-p/418004#M73762</link>
    <description>&lt;P&gt;Hi quadealexander,&lt;BR /&gt;
if you use _time it's ery easy because timestamp is already in epochtime, so you can use something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | head 1 | eval diff=now()-_time | table _time diff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;result is expressed in seconds.&lt;/P&gt;

&lt;P&gt;If instead you want to compare a date with the current time, you have to transform it using the strptime function.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jun 2019 13:42:48 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2019-06-11T13:42:48Z</dc:date>
    <item>
      <title>Compare/calculate with current date</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Compare-calculate-with-current-date/m-p/418003#M73761</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I want to create automatic obsolecance reports in Splunk. I grab the info from a database. There is a collum that has the obsolecance date in it. &lt;BR /&gt;
Now I want to compare that date with the current date when the job is run and depending on how much time is left between them they get an obso_status (12 moths or less-&amp;gt; obso_satus 1 and so on). The dates look like this: 2012-11-30 00:00:00.0&lt;/P&gt;

&lt;P&gt;Does someone has suggestions on how to do this?&lt;BR /&gt;
thx in advance&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:52:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Compare-calculate-with-current-date/m-p/418003#M73761</guid>
      <dc:creator>quadealexander</dc:creator>
      <dc:date>2020-09-30T00:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Compare/calculate with current date</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Compare-calculate-with-current-date/m-p/418004#M73762</link>
      <description>&lt;P&gt;Hi quadealexander,&lt;BR /&gt;
if you use _time it's ery easy because timestamp is already in epochtime, so you can use something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | head 1 | eval diff=now()-_time | table _time diff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;result is expressed in seconds.&lt;/P&gt;

&lt;P&gt;If instead you want to compare a date with the current time, you have to transform it using the strptime function.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 13:42:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Compare-calculate-with-current-date/m-p/418004#M73762</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-11T13:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Compare/calculate with current date</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Compare-calculate-with-current-date/m-p/418005#M73763</link>
      <description>&lt;P&gt;This should get you started.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbxquery ... | eval obso_date=strptime(obsolecanceDate, "%Y-%m-%d %H:%M:%S.%N") | eval obso_status=case((obso_date-now()) &amp;lt; (86400*365), 1, &amp;lt;so on&amp;gt;) | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jun 2019 13:55:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Compare-calculate-with-current-date/m-p/418005#M73763</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-06-11T13:55:33Z</dc:date>
    </item>
  </channel>
</rss>

