<?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: Splunk date comparison in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47456#M11320</link>
    <description>&lt;P&gt;If &lt;CODE&gt;Start_Date&lt;/CODE&gt; is an extracted field you can just add it to the search in a key=value format, e.g;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=blah sourcetype=bleh Start_Date=08/26/2013*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it is &lt;EM&gt;not&lt;/EM&gt; an extracted field, and you do not wish it to be, you can extract within the search first;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=blah sourcetype=bleh | rex "Start_Date:\s(?&amp;lt;Start_Date&amp;gt;\S+)" | search Start_Date=06/26/2013*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your use of &lt;CODE&gt;strftime/strptime&lt;/CODE&gt; is not correct. Those two are functions of &lt;CODE&gt;eval&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;K&lt;/P&gt;</description>
    <pubDate>Tue, 27 Aug 2013 11:42:46 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2013-08-27T11:42:46Z</dc:date>
    <item>
      <title>Splunk date comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47454#M11318</link>
      <description>&lt;P&gt;I need to be able to search for log entries with a specific start date, which has nothing to do with &lt;CODE&gt;_time&lt;/CODE&gt;. The format is, for example, &lt;CODE&gt;Start_Date: 08/26/2013 4:30 PM&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;I need to add a condition in my search to specify the date, but not the time. I tried &lt;CODE&gt;strptime&lt;/CODE&gt; and &lt;CODE&gt;strftime&lt;/CODE&gt; unsuccessfully.&lt;/P&gt;

&lt;P&gt;For example, I tried converting start date to a string (without time) and compare it to another string:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"08/26/2013"=strftime(Start_Date, "%d/%m/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This didn't work either:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; "08/26/2013"=strftime(strptime(Start_Date "%d/%m/%Y %I:%M %p"), "%d/%m/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas how to solve this?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2013 11:22:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47454#M11318</guid>
      <dc:creator>mcamilleri</dc:creator>
      <dc:date>2013-08-27T11:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk date comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47455#M11319</link>
      <description>&lt;P&gt;Use &lt;BR /&gt;
search sourcetype="comparison" | eval existing_date=functions()&lt;BR /&gt;
instead of comparing between 2 different dates of your search solve&lt;BR /&gt;
evaluation function instead of equal sign, 2 different dates can not be equal try to use your existing dates to be compatible with your start_date format&lt;/P&gt;

&lt;P&gt;Hope this will help.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:39:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47455#M11319</guid>
      <dc:creator>royimad</dc:creator>
      <dc:date>2020-09-28T14:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk date comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47456#M11320</link>
      <description>&lt;P&gt;If &lt;CODE&gt;Start_Date&lt;/CODE&gt; is an extracted field you can just add it to the search in a key=value format, e.g;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=blah sourcetype=bleh Start_Date=08/26/2013*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it is &lt;EM&gt;not&lt;/EM&gt; an extracted field, and you do not wish it to be, you can extract within the search first;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=blah sourcetype=bleh | rex "Start_Date:\s(?&amp;lt;Start_Date&amp;gt;\S+)" | search Start_Date=06/26/2013*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your use of &lt;CODE&gt;strftime/strptime&lt;/CODE&gt; is not correct. Those two are functions of &lt;CODE&gt;eval&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;K&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2013 11:42:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47456#M11320</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-08-27T11:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk date comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47457#M11321</link>
      <description>&lt;P&gt;If you want to use comparison operators instead of just making sure the string is equal to "08/26/2013 4:30 PM" (e.g. "return all events that have a start date &lt;EM&gt;after&lt;/EM&gt; 09/24/2012"), you will need to convert the time into epoch seconds.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;base search&amp;gt; | eval start-epoch=strptime(Start_Date, "%m/%d/%Y %I:%M %p")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you a new field &lt;STRONG&gt;start-epoch&lt;/STRONG&gt; that may be used for comparison purposes.&lt;/P&gt;

&lt;P&gt;NOTE: This assumes you have a field called &lt;STRONG&gt;Start_Date&lt;/STRONG&gt;. If you do not, you will need to extract the date similarly to how kristian.kolb did in the other answer provided.&lt;/P&gt;

&lt;P&gt;Hope this helps! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;References:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.4/SearchReference/Commontimeformatvariables"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.4/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.4/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.4/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://answers.splunk.com/answers/37272/compare-two-date"&gt;http://answers.splunk.com/answers/37272/compare-two-date&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 27 Aug 2013 12:17:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47457#M11321</guid>
      <dc:creator>rturk</dc:creator>
      <dc:date>2013-08-27T12:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk date comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47458#M11322</link>
      <description>&lt;P&gt;Thanks! &lt;CODE&gt;Start_Date=08/26/2013*&lt;/CODE&gt; works perfectly.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2013 12:59:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-date-comparison/m-p/47458#M11322</guid>
      <dc:creator>mcamilleri</dc:creator>
      <dc:date>2013-08-27T12:59:54Z</dc:date>
    </item>
  </channel>
</rss>

