<?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 to find events between date ranges? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-events-between-date-ranges/m-p/320981#M95887</link>
    <description>&lt;P&gt;This has been answered but using the methods still do not provide the right results. &lt;BR /&gt;
I have a date column.  Format is like 4/2/2018.&lt;BR /&gt;
I need to be able to find the events between date ranges.  I've tried the conversion methods posted in answers, but when I do a WHERE Date&amp;gt;="4/2/2018" AND Date&amp;lt;="4/10/2018" the results pull a huge range of dates within 4/2018.&lt;/P&gt;

&lt;P&gt;Cheers ~ &lt;/P&gt;</description>
    <pubDate>Thu, 05 Apr 2018 13:24:55 GMT</pubDate>
    <dc:creator>jimbolya11</dc:creator>
    <dc:date>2018-04-05T13:24:55Z</dc:date>
    <item>
      <title>How to find events between date ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-events-between-date-ranges/m-p/320981#M95887</link>
      <description>&lt;P&gt;This has been answered but using the methods still do not provide the right results. &lt;BR /&gt;
I have a date column.  Format is like 4/2/2018.&lt;BR /&gt;
I need to be able to find the events between date ranges.  I've tried the conversion methods posted in answers, but when I do a WHERE Date&amp;gt;="4/2/2018" AND Date&amp;lt;="4/10/2018" the results pull a huge range of dates within 4/2018.&lt;/P&gt;

&lt;P&gt;Cheers ~ &lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 13:24:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-events-between-date-ranges/m-p/320981#M95887</guid>
      <dc:creator>jimbolya11</dc:creator>
      <dc:date>2018-04-05T13:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to find events between date ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-events-between-date-ranges/m-p/320982#M95888</link>
      <description>&lt;P&gt;Dates cannot be compared as strings.  You must convert them to integer (epoch) form for proper comparison.  Try this in your query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where (strptime(Date, "%m/%d/%Y")&amp;gt;=strptime("4/2/2018", "%m/%d/%Y")) AND (strptime(Date, "%m/%d/%Y")&amp;gt;=strptime("4/10/2018", "%m/%d/%Y")) | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Apr 2018 15:52:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-events-between-date-ranges/m-p/320982#M95888</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-04-05T15:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to find events between date ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-events-between-date-ranges/m-p/320983#M95889</link>
      <description>&lt;P&gt;For Date conversion, see this -&amp;gt; &lt;A href="https://answers.splunk.com/answers/638427/convert-string-to-date-1.html"&gt;https://answers.splunk.com/answers/638427/convert-string-to-date-1.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Your &lt;CODE&gt;WHERE&lt;/CODE&gt; command is comparing a timestamp to a string.  You'll need to convert the string to a timestamp.  Here is an example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval Date="4/2/2018" 
| eval timestampDate=strptime(Date, "%m/%d/%Y") 
| eval timestampStart=strptime("4/2/2018", "%m/%d/%Y") 
| eval timestampEnd=strptime("4/10/2018", "%m/%d/%Y") 
| eval formattedTimestamp = strftime(timestamp,"%Y-%m-%dT%H:%M:%S") 
| where timestampDate &amp;gt;= timestampStart AND timestampDate &amp;lt;= timestampEnd
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:07:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-events-between-date-ranges/m-p/320983#M95889</guid>
      <dc:creator>jconger</dc:creator>
      <dc:date>2018-04-05T16:07:08Z</dc:date>
    </item>
  </channel>
</rss>

