<?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: Search for Entries Between DateTime field value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-Entries-Between-DateTime-field-value/m-p/630869#M219151</link>
    <description>&lt;P&gt;You can't do these type of criteria on the search command, as parsing data has to be done in the eval - unless you set up a calculated field that does these evals for you.&lt;/P&gt;&lt;P&gt;This is how you would do it&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=myindex) 
| eval Date_value=strptime(Date, "%Y-%m-%d %H:%M:%S")
| eval min_Date=strptime("2023-02-11 00:00:00", "%Y-%m-%d %H:%M:%S")
| eval max_Date=strptime("2023-02-12 00:00:00", "%Y-%m-%d %H:%M:%S")
| where (Date_value &amp;gt;= min_Date AND Date_value &amp;lt; max_Date&lt;/LI-CODE&gt;&lt;P&gt;Note that your second comparison said &lt;EM&gt;&lt;STRONG&gt;&amp;gt;=&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;but I imagine you means &amp;lt;=.&lt;/P&gt;&lt;P&gt;However, I also changed the second strptime for end date to be 00:00:00 on the 12th and used less than rather than &amp;lt;=, as yours will miss any events that come in between 23:59:59 and 00:00:00 (1000 milliseconds gap).&lt;/P&gt;&lt;P&gt;Note that your data range is always searched by the _time field, so if your Date field has the same value as the _time field, then you don't need any of this, you just use earliest/latest values in the search or time picker.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2023 21:00:36 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2023-02-14T21:00:36Z</dc:date>
    <item>
      <title>How to search for Entries Between DateTime field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-Entries-Between-DateTime-field-value/m-p/630861#M219148</link>
      <description>&lt;P class="lia-align-left"&gt;I am trying to find entries between a date-time range based on a field in the event 'Date'. It date-time value of the field is in the format - %Y-%m-%d %H:%M:%S.&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;I am using below query:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="java"&gt;(index=myindex) ((strptime(Date, "%Y-%m-%d %H:%M:%S")&amp;gt;=strptime("2023-02-11 00:00:00", "%Y-%m-%d %H:%M:%S")) AND (strptime(Date, "%Y-%m-%d %H:%M:%S")&amp;gt;=strptime("2023-02-11 23:59:59", "%Y-%m-%d %H:%M:%S")))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;It is giving me below Error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="java"&gt;Error in 'search' command: Unable to parse the search: Comparator '&amp;gt;=' has an invalid term on the left hand side: (Date "%Y-%m-%d %H:%M:%S"). &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;Sample Data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
  "InterfaceNumber": "I-XXXX",
  "SystemCode": "sys",
  "Element": "JobID:bw0a104of",
  "Data": "",
  "Severity": "Error",
  "ProcessContext_ProcessId": "bw0a104of",
  "Subject": "/api/login",
  "Date": "2023-02-14 12:25:01",
  "ErrorMessages": "This is an Error",
  "ProcessContext_ProjectName": "MyApp.application",
  "HostName": "localhost.mydomain.com",
  "ProcessContext_RestartedFromCheckpoint": false,
  "ProcessContext_EngineName": "MyApp"
 }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;Not sure what I am doing wrong. Any help appreciated.&lt;/P&gt;
&lt;P class="lia-align-left"&gt;--&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 22:20:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-Entries-Between-DateTime-field-value/m-p/630861#M219148</guid>
      <dc:creator>akpuvvada</dc:creator>
      <dc:date>2023-02-14T22:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Entries Between DateTime field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-Entries-Between-DateTime-field-value/m-p/630869#M219151</link>
      <description>&lt;P&gt;You can't do these type of criteria on the search command, as parsing data has to be done in the eval - unless you set up a calculated field that does these evals for you.&lt;/P&gt;&lt;P&gt;This is how you would do it&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=myindex) 
| eval Date_value=strptime(Date, "%Y-%m-%d %H:%M:%S")
| eval min_Date=strptime("2023-02-11 00:00:00", "%Y-%m-%d %H:%M:%S")
| eval max_Date=strptime("2023-02-12 00:00:00", "%Y-%m-%d %H:%M:%S")
| where (Date_value &amp;gt;= min_Date AND Date_value &amp;lt; max_Date&lt;/LI-CODE&gt;&lt;P&gt;Note that your second comparison said &lt;EM&gt;&lt;STRONG&gt;&amp;gt;=&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;but I imagine you means &amp;lt;=.&lt;/P&gt;&lt;P&gt;However, I also changed the second strptime for end date to be 00:00:00 on the 12th and used less than rather than &amp;lt;=, as yours will miss any events that come in between 23:59:59 and 00:00:00 (1000 milliseconds gap).&lt;/P&gt;&lt;P&gt;Note that your data range is always searched by the _time field, so if your Date field has the same value as the _time field, then you don't need any of this, you just use earliest/latest values in the search or time picker.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 21:00:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-Entries-Between-DateTime-field-value/m-p/630869#M219151</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-02-14T21:00:36Z</dc:date>
    </item>
  </channel>
</rss>

