<?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 events in a specific time range in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-for-events-in-a-specific-time-range/m-p/45427#M10771</link>
    <description>&lt;P&gt;Great thanks I'll try it&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jul 2011 06:06:20 GMT</pubDate>
    <dc:creator>bhiley</dc:creator>
    <dc:date>2011-07-20T06:06:20Z</dc:date>
    <item>
      <title>Search for events in a specific time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-events-in-a-specific-time-range/m-p/45425#M10769</link>
      <description>&lt;P&gt;I have data eg. as follows :-&lt;/P&gt;

&lt;P&gt;rectype=031 OMD_StrtTime_002="Wed Jul 20 02:59:59 2011" OMD_Endtime_003="Wed Jul 20 03:59:57 2011" etc&lt;/P&gt;

&lt;P&gt;Splunk correctly extracts the first datetime as the timestamp for the event (and I assume it identifies the second one as a timestamp ?)&lt;BR /&gt;
I want to search for events where OMD_StrtTime_002 &amp;gt; 'some specified value' and OMD_Endtime_003 &amp;lt; 'some specified value' - what is the syntax for the query ?&lt;BR /&gt;
Can't seem to find an example on Splunkbase that applies or write one that works.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:44:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-events-in-a-specific-time-range/m-p/45425#M10769</guid>
      <dc:creator>bhiley</dc:creator>
      <dc:date>2020-09-28T09:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Search for events in a specific time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-events-in-a-specific-time-range/m-p/45426#M10770</link>
      <description>&lt;P&gt;Assuming that splunk is already extracting these values as fields (which it should be), the easiest thing to do is convert everything to time_t.  These are simple integers, easily compared.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rectype=031
| eval OMD_Strt_t=strptime(OMD_StrtTime_002,"%A %B %d %H:%M:%S %Y")
| eval OMD_End_t=strptime(OMD_Endtime_003,"%A %B %d %H:%M:%S %Y")
| eval target_start=strptime("Wed Jul 20 01:00:00 2011","%A %B %d %H:%M:%S %Y")
| eval target_end=strptime("Wed Jul 20 05:00:00 2011","%A %B %d %H:%M:%S %Y")
| where OMD_Strt_t &amp;gt; target_start AND OMD_End_t &amp;lt; target_end
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's a bit of hoop jumping just to get everything into nice, easy, comparable time_t integers, but it is worth it from a personal sanity point of view.&lt;/P&gt;

&lt;P&gt;The problem here is that Splunk parses a timestamp from the event and stores it into &lt;CODE&gt;_time&lt;/CODE&gt;, and you can limit your timerange to a specific range of &lt;CODE&gt;_time&lt;/CODE&gt; values using &lt;CODE&gt;earliest=&lt;/CODE&gt; and &lt;CODE&gt;latest=&lt;/CODE&gt;.  But, it doesn't &lt;STRONG&gt;implicitly&lt;/STRONG&gt; see any other timestamp in the event as anything other than a string.  You have to do something to parse it into something that is comparable.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2011 02:18:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-events-in-a-specific-time-range/m-p/45426#M10770</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-07-20T02:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Search for events in a specific time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-events-in-a-specific-time-range/m-p/45427#M10771</link>
      <description>&lt;P&gt;Great thanks I'll try it&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2011 06:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-events-in-a-specific-time-range/m-p/45427#M10771</guid>
      <dc:creator>bhiley</dc:creator>
      <dc:date>2011-07-20T06:06:20Z</dc:date>
    </item>
  </channel>
</rss>

