<?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 Date Comparison with current date in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/466297#M131300</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to display results in separate panels based on date fields in my dataset. I want to display results where Date1 is less than 7 days from current date and &lt;BR /&gt;
in separate panel , I want to display results where Date 2 is less than 7 days from current date. &lt;/P&gt;

&lt;P&gt;I tried using eval but it doesn't provide any results &lt;/P&gt;

&lt;P&gt;Queries that I tried:&lt;BR /&gt;
|inputlookup devices_lookup |eval _time=strptime(Date1, "%m/%d/%Y") |search latest=-7d&lt;/P&gt;

&lt;P&gt;|inputlookup devices_lookup |eval Test=substr(Date2, 0,10)| eval _time=strptime(Date2, "%m/%d/%Y") |search latest=-7d&lt;/P&gt;

&lt;P&gt;Is there any way to perform this using standard date functions as I have NULL values in Date1, Date2 columns too which I want to handle. &lt;BR /&gt;
I have also attached sample data here. &lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7849i3206844F3C5AF6CC/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks ! &lt;BR /&gt;
Rohan K&lt;/P&gt;</description>
    <pubDate>Fri, 25 Oct 2019 18:36:43 GMT</pubDate>
    <dc:creator>rohankin</dc:creator>
    <dc:date>2019-10-25T18:36:43Z</dc:date>
    <item>
      <title>Date Comparison with current date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/466297#M131300</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to display results in separate panels based on date fields in my dataset. I want to display results where Date1 is less than 7 days from current date and &lt;BR /&gt;
in separate panel , I want to display results where Date 2 is less than 7 days from current date. &lt;/P&gt;

&lt;P&gt;I tried using eval but it doesn't provide any results &lt;/P&gt;

&lt;P&gt;Queries that I tried:&lt;BR /&gt;
|inputlookup devices_lookup |eval _time=strptime(Date1, "%m/%d/%Y") |search latest=-7d&lt;/P&gt;

&lt;P&gt;|inputlookup devices_lookup |eval Test=substr(Date2, 0,10)| eval _time=strptime(Date2, "%m/%d/%Y") |search latest=-7d&lt;/P&gt;

&lt;P&gt;Is there any way to perform this using standard date functions as I have NULL values in Date1, Date2 columns too which I want to handle. &lt;BR /&gt;
I have also attached sample data here. &lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7849i3206844F3C5AF6CC/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks ! &lt;BR /&gt;
Rohan K&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 18:36:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/466297#M131300</guid>
      <dc:creator>rohankin</dc:creator>
      <dc:date>2019-10-25T18:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Date Comparison with current date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/466298#M131301</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup devices_lookup
| eval _time=strptime(Date1, "%m/%d/%Y")
| where _time &amp;lt;= relative_time(now(), "-7d")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Oct 2019 19:50:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/466298#M131301</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-25T19:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Date Comparison with current date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/466299#M131302</link>
      <description>&lt;P&gt;Thanks ! That worked. I just noticed my data also has many rows where date is "12/31/1969 07:10 pm" which is UNIX timestamp 0. strptime doesnt work on that. Any suggestion on how I should handle this ? &lt;BR /&gt;
I am thinking of changing that date to "0" or "missing" to reflect the fact that "Date" field is not being populated for those devices. &lt;/P&gt;

&lt;P&gt;Any idea how should I do that ? &lt;/P&gt;

&lt;P&gt;Thanks ! &lt;BR /&gt;
Rohan K. &lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 12:43:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/466299#M131302</guid>
      <dc:creator>rohankin</dc:creator>
      <dc:date>2019-10-30T12:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Date Comparison with current date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/466300#M131303</link>
      <description>&lt;P&gt;Fix your data onboarding.  DO NOT LET SPLUNK GUESS WHERE/WHAT THE TIMESTAMP IS!  Google &lt;CODE&gt;splunk Magic 8&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 19:38:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/466300#M131303</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-31T19:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Date Comparison with current date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/577900#M201381</link>
      <description>&lt;P&gt;I have a query on top of this..&amp;nbsp;&lt;/P&gt;&lt;P&gt;What if i want to use the token instead of "Date1" ?&lt;/P&gt;&lt;P&gt;means the date which is being selected from drop down.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 14:08:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-Comparison-with-current-date/m-p/577900#M201381</guid>
      <dc:creator>koreamit3483</dc:creator>
      <dc:date>2021-12-09T14:08:35Z</dc:date>
    </item>
  </channel>
</rss>

