<?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: Current date exclusion from search events in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Current-date-exclusion-from-search-events/m-p/95095#M19819</link>
    <description>&lt;P&gt;1 - Extract the boundaries of your time range into their own fields. Let's say   &lt;CODE&gt;latest_time_boundary&lt;/CODE&gt;  and  &lt;CODE&gt;earliest_time_boundary&lt;/CODE&gt;. You can use an inline &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex" target="_blank"&gt;rex&lt;/A&gt; to do this.&lt;/P&gt;

&lt;P&gt;Quick and dirty example :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex (?&amp;lt;earliest_time_boundary&amp;gt;(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)-(?&amp;lt;latest_time_boundary&amp;gt;\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2 - Use &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Convert" target="_blank"&gt;convert's mktime() function&lt;/A&gt; to convert the boundaries of your time range to epoch times. This would look like :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| convert timeformat=%Y-%m-%dT%H:%M:%S.%3NZ mktime(latest_time_boundary)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;3 - Using eval, create a new field that shows the delta in seconds between the time at which the search ran (&lt;CODE&gt;now()&lt;/CODE&gt;) and the upper boundary of the time range :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval elapsed_seconds=(now() - latest_time_boundary)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;4 - Exclude any events for which that delta is less than 24 hours / 86,400 seconds :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search elapsed_seconds&amp;gt;86400
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Sep 2020 10:00:20 GMT</pubDate>
    <dc:creator>hexx</dc:creator>
    <dc:date>2020-09-28T10:00:20Z</dc:date>
    <item>
      <title>Current date exclusion from search events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Current-date-exclusion-from-search-events/m-p/95094#M19818</link>
      <description>&lt;P&gt;I have an event that contains the following date format/range text within it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2011-10-07T00:00:00.000Z-2011-10-07T12:00:00.000Z
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to exclude any events whose second part of that range (in this case 2011-10-07T12:00:00.000Z) are within 24hrs of current time.&lt;/P&gt;

&lt;P&gt;I have tried using now() with fields and reformatting, then using rex mode=sed to exclude now() but I am missing something.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2011 00:24:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Current-date-exclusion-from-search-events/m-p/95094#M19818</guid>
      <dc:creator>drewbfl</dc:creator>
      <dc:date>2011-10-20T00:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Current date exclusion from search events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Current-date-exclusion-from-search-events/m-p/95095#M19819</link>
      <description>&lt;P&gt;1 - Extract the boundaries of your time range into their own fields. Let's say   &lt;CODE&gt;latest_time_boundary&lt;/CODE&gt;  and  &lt;CODE&gt;earliest_time_boundary&lt;/CODE&gt;. You can use an inline &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex" target="_blank"&gt;rex&lt;/A&gt; to do this.&lt;/P&gt;

&lt;P&gt;Quick and dirty example :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex (?&amp;lt;earliest_time_boundary&amp;gt;(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)-(?&amp;lt;latest_time_boundary&amp;gt;\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2 - Use &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Convert" target="_blank"&gt;convert's mktime() function&lt;/A&gt; to convert the boundaries of your time range to epoch times. This would look like :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| convert timeformat=%Y-%m-%dT%H:%M:%S.%3NZ mktime(latest_time_boundary)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;3 - Using eval, create a new field that shows the delta in seconds between the time at which the search ran (&lt;CODE&gt;now()&lt;/CODE&gt;) and the upper boundary of the time range :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval elapsed_seconds=(now() - latest_time_boundary)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;4 - Exclude any events for which that delta is less than 24 hours / 86,400 seconds :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search elapsed_seconds&amp;gt;86400
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:00:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Current-date-exclusion-from-search-events/m-p/95095#M19819</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2020-09-28T10:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Current date exclusion from search events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Current-date-exclusion-from-search-events/m-p/95096#M19820</link>
      <description>&lt;P&gt;Thanks, worked perfect!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2011 01:49:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Current-date-exclusion-from-search-events/m-p/95096#M19820</guid>
      <dc:creator>drewbfl</dc:creator>
      <dc:date>2011-10-20T01:49:54Z</dc:date>
    </item>
  </channel>
</rss>

