<?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: Run search only on data for certain time of day in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Run-search-only-on-data-for-certain-time-of-day/m-p/113397#M29814</link>
    <description>&lt;P&gt;If you search is really correct (highly questionable, IMHO, because the date* fields are pre-TZ-normalized fields), then you can shift the time like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=10  | eval _time=_time - 2*60*60 | eval date_hour=strftime(_time, "%H") | where (date_hour&amp;lt;6 OR date_hour&amp;gt;18) | bucket _time span=12h | stats sum(AMOUNT) as total by COUNTRY _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This recalculates &lt;CODE&gt;date_hour&lt;/CODE&gt; to be sure it is correct (and so you may not even need the time shift, because this was probably your original problem).&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jul 2015 20:00:46 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-07-10T20:00:46Z</dc:date>
    <item>
      <title>Run search only on data for certain time of day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Run-search-only-on-data-for-certain-time-of-day/m-p/113396#M29813</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am attempting to run a search that will only include data occurring before 6 AM or after 6 PM, then group the data by 12 hour time range and country, and sum the total amount for each time period. For example, I want the sum of the data for each country in time periods such as Monday 6 PM - Tuesday 6 AM, Tuesday 6 PM - Wednesday 6 AM, etc.&lt;/P&gt;

&lt;P&gt;This is the code I have:&lt;/P&gt;

&lt;P&gt;host=10 AND (date_hour&amp;lt;6 OR date_hour&amp;gt;18) | bucket _time span=12h | stats sum(AMOUNT) as total by COUNTRY _time&lt;/P&gt;

&lt;P&gt;This query is limiting my data to only those that occured before 6 AM or after 6 PM, but it reporting is as Monday 8 PM - Tueday 8 AM (with the data between Tuesday 6 AM-8AM excluded), Tuesday 8 AM - Tuesday 8 PM (with the data between T 8 AM and 6 PM excluded), etc. Is there any way so that the reported time frame is from 6 to 6, instead of from 8 to 8?&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 06:38:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Run-search-only-on-data-for-certain-time-of-day/m-p/113396#M29813</guid>
      <dc:creator>heilman</dc:creator>
      <dc:date>2020-09-29T06:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Run search only on data for certain time of day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Run-search-only-on-data-for-certain-time-of-day/m-p/113397#M29814</link>
      <description>&lt;P&gt;If you search is really correct (highly questionable, IMHO, because the date* fields are pre-TZ-normalized fields), then you can shift the time like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=10  | eval _time=_time - 2*60*60 | eval date_hour=strftime(_time, "%H") | where (date_hour&amp;lt;6 OR date_hour&amp;gt;18) | bucket _time span=12h | stats sum(AMOUNT) as total by COUNTRY _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This recalculates &lt;CODE&gt;date_hour&lt;/CODE&gt; to be sure it is correct (and so you may not even need the time shift, because this was probably your original problem).&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2015 20:00:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Run-search-only-on-data-for-certain-time-of-day/m-p/113397#M29814</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-10T20:00:46Z</dc:date>
    </item>
  </channel>
</rss>

