<?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 Splunk compare date strings by queries in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-compare-date-strings-by-queries/m-p/428554#M122596</link>
    <description>&lt;P&gt;I want to compare date strings by splunk queries please. I have 2 dropdown inputs. &lt;CODE&gt;StartDate&lt;/CODE&gt; and &lt;CODE&gt;EndDate&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I have below result set populated from a dropdown as 'StartDate'. If the user selects &lt;CODE&gt;2018-05-03&lt;/CODE&gt;, then my &lt;CODE&gt;EndDate&lt;/CODE&gt; should only have &lt;CODE&gt;2018-05-07&lt;/CODE&gt; and &lt;CODE&gt;2018-05-16&lt;/CODE&gt; available for users to pick.&lt;BR /&gt;
&lt;CODE&gt;Date&lt;BR /&gt;
2018-05-01&lt;BR /&gt;
2018-05-03&lt;BR /&gt;
2018-05-07&lt;BR /&gt;
201805-16&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;How do I do the comparison logic  within the same query please? Can Splunk compare dates alphabetically like Java strings ? Thank you. &lt;/P&gt;</description>
    <pubDate>Tue, 05 Jun 2018 01:29:35 GMT</pubDate>
    <dc:creator>h52huang</dc:creator>
    <dc:date>2018-06-05T01:29:35Z</dc:date>
    <item>
      <title>Splunk compare date strings by queries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-compare-date-strings-by-queries/m-p/428554#M122596</link>
      <description>&lt;P&gt;I want to compare date strings by splunk queries please. I have 2 dropdown inputs. &lt;CODE&gt;StartDate&lt;/CODE&gt; and &lt;CODE&gt;EndDate&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I have below result set populated from a dropdown as 'StartDate'. If the user selects &lt;CODE&gt;2018-05-03&lt;/CODE&gt;, then my &lt;CODE&gt;EndDate&lt;/CODE&gt; should only have &lt;CODE&gt;2018-05-07&lt;/CODE&gt; and &lt;CODE&gt;2018-05-16&lt;/CODE&gt; available for users to pick.&lt;BR /&gt;
&lt;CODE&gt;Date&lt;BR /&gt;
2018-05-01&lt;BR /&gt;
2018-05-03&lt;BR /&gt;
2018-05-07&lt;BR /&gt;
201805-16&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;How do I do the comparison logic  within the same query please? Can Splunk compare dates alphabetically like Java strings ? Thank you. &lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 01:29:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-compare-date-strings-by-queries/m-p/428554#M122596</guid>
      <dc:creator>h52huang</dc:creator>
      <dc:date>2018-06-05T01:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk compare date strings by queries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-compare-date-strings-by-queries/m-p/428555#M122597</link>
      <description>&lt;P&gt;In this case you can do a string comparison in order to test the dates. Here is a &lt;EM&gt;run-anywhere&lt;/EM&gt;  search (it sets up some data in the first three lines, then the last line is the one you want to look at) that can show you this capability:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval data="date1=2018-05-03 date2=2018-05-07"
| rex field=data "date1=(?P&amp;lt;date1&amp;gt;\S+)\s+date2=(?P&amp;lt;date2&amp;gt;\S+)"
| eval less=if(date1&amp;lt;date2,1,0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The dates are compared as strings. The &lt;CODE&gt;if&lt;/CODE&gt; function will allow you to do a comparison, then if true, take the first value, if false, take the second value.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 01:43:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-compare-date-strings-by-queries/m-p/428555#M122597</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-06-05T01:43:20Z</dc:date>
    </item>
  </channel>
</rss>

