<?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 Time-Modifiers Search depending on the day in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Time-Modifiers-Search-depending-on-the-day/m-p/37158#M8271</link>
    <description>&lt;P&gt;Hi. Im using a Saved Search in a dashboard and cant manage to find if what i want to do is possible.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I want my search to be from last friday 6PM to monday 8AM IF WE ARE MONDAY.&lt;/LI&gt;
&lt;LI&gt;I want my search to be from last day 6PM to this day 8AM THE OTHER DAYS.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;The fact is when i start my day i want to see night events, and when its monday i want to see events of the week-end from friday 6PM to now.&lt;/P&gt;

&lt;P&gt;Is it possible to do this with only one "search" ? &lt;BR /&gt;
Today i use 2 searchs which are the same instead the time-modifiers:&lt;/P&gt;

&lt;P&gt;For the week-end view:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;earliest_time = @w1-2d-6h&lt;/LI&gt;
&lt;LI&gt;latest_time = @w1+8h&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;For the night view:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;earliest_time = @d-6h&lt;/LI&gt;
&lt;LI&gt;latest_time = @d+8h&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Fri, 16 Aug 2013 08:16:33 GMT</pubDate>
    <dc:creator>timmalos</dc:creator>
    <dc:date>2013-08-16T08:16:33Z</dc:date>
    <item>
      <title>Time-Modifiers Search depending on the day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-Modifiers-Search-depending-on-the-day/m-p/37158#M8271</link>
      <description>&lt;P&gt;Hi. Im using a Saved Search in a dashboard and cant manage to find if what i want to do is possible.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I want my search to be from last friday 6PM to monday 8AM IF WE ARE MONDAY.&lt;/LI&gt;
&lt;LI&gt;I want my search to be from last day 6PM to this day 8AM THE OTHER DAYS.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;The fact is when i start my day i want to see night events, and when its monday i want to see events of the week-end from friday 6PM to now.&lt;/P&gt;

&lt;P&gt;Is it possible to do this with only one "search" ? &lt;BR /&gt;
Today i use 2 searchs which are the same instead the time-modifiers:&lt;/P&gt;

&lt;P&gt;For the week-end view:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;earliest_time = @w1-2d-6h&lt;/LI&gt;
&lt;LI&gt;latest_time = @w1+8h&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;For the night view:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;earliest_time = @d-6h&lt;/LI&gt;
&lt;LI&gt;latest_time = @d+8h&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 16 Aug 2013 08:16:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-Modifiers-Search-depending-on-the-day/m-p/37158#M8271</guid>
      <dc:creator>timmalos</dc:creator>
      <dc:date>2013-08-16T08:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Time-Modifiers Search depending on the day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-Modifiers-Search-depending-on-the-day/m-p/37159#M8272</link>
      <description>&lt;P&gt;Best way will be for the weekdays, run it everyday at 8 AM till Saturday morning using cron-schedule&lt;BR /&gt;
with &lt;BR /&gt;
earliest_time = @d-6h&lt;BR /&gt;
latest_time = @d+8h&lt;/P&gt;

&lt;P&gt;And for the weekend you can do &lt;/P&gt;

&lt;P&gt;earliest_time=-1w@w6-6h&lt;BR /&gt;
latest_time=@w1+8h&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:35:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-Modifiers-Search-depending-on-the-day/m-p/37159#M8272</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2020-09-28T14:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Time-Modifiers Search depending on the day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-Modifiers-Search-depending-on-the-day/m-p/37160#M8273</link>
      <description>&lt;P&gt;If you would like to search for one, How is such a feeling, for example, if I use the NOW ()?&lt;/P&gt;

&lt;P&gt;(week=="1" is Monday)ex.&lt;BR /&gt;
index=*  [| stats count |eval week=strftime(now(),"%w") |eval earliest=if(week=="1","@w1-2d-6h","@d-6h") |eval latest=if(week=="1","@w1+8h","@d+8h")| return earliest latest]&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2013 08:52:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-Modifiers-Search-depending-on-the-day/m-p/37160#M8273</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2013-08-19T08:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Time-Modifiers Search depending on the day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-Modifiers-Search-depending-on-the-day/m-p/37161#M8274</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;earliest=-3d@d+18h 
| eval run_day=strftime(now(),"%A") 
| eval today_midnight = strptime(strftime(now(),"%F"),"%s")
| eval mond_start = tonight_midnight - (86400 + 86400 + 21600)
| eval other_start = tonight_midnight - 21600
| eval stop = tonight_midnight + 28800
| eval start = if(run_day=="Monday",mond_start,other_start) 
| where _time &amp;gt; start _time &amp;lt; stop 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This ought to work, even though I have not tested it. Short breakdown;&lt;/P&gt;

&lt;P&gt;line1: at most we will need to look back to 6PM 3 days ago&lt;BR /&gt;
line2: find out if what day it is today, i.e. when we're running the search&lt;BR /&gt;
line3: determine the epoch timestamp for midnight on the day the search is run&lt;BR /&gt;
line4: define the epoch timestamp for 6PM three days ago&lt;BR /&gt;
line5: define the epoch timestamp for 6PM yesterday&lt;BR /&gt;
line6: define the epoch timestamp for 8AM today&lt;BR /&gt;
line7: depending on todays weekday, define 'start' as 6PM three days ago, or 6PM yesterday&lt;BR /&gt;
line8: restrict results based on &lt;CODE&gt;_time&lt;/CODE&gt;   &lt;/P&gt;

&lt;P&gt;This could probably be shortened a bit, but for sake of simplicity there are a lot of &lt;CODE&gt;eval&lt;/CODE&gt;s.&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;K&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2013 09:09:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-Modifiers-Search-depending-on-the-day/m-p/37161#M8274</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-08-19T09:09:17Z</dc:date>
    </item>
  </channel>
</rss>

