<?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: How to edit my search to filter out from Sunday through Saturday date range? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239772#M71238</link>
    <description>&lt;P&gt;yes I see the dates but the example above brings me the data from Sunday the 8th till now. This is what I am trying to do. Giving today's date of 1/17/17 TUESDAY bring me the following data:&lt;BR /&gt;
1/15/17 - 1/17/17 =&amp;gt; This week - Sunday through Tuesday (today's date)&lt;BR /&gt;
1/08/17 - 1/14/17 =&amp;gt; Previous week&lt;BR /&gt;
1/01/17 - 1/07/17 =&amp;gt; The week before previous week&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jan 2017 19:50:50 GMT</pubDate>
    <dc:creator>maximusdm</dc:creator>
    <dc:date>2017-01-17T19:50:50Z</dc:date>
    <item>
      <title>How to edit my search to filter out from Sunday through Saturday date range?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239768#M71234</link>
      <description>&lt;P&gt;How do I present data from 2 weeks ago, last week and current week based on the following rule:&lt;BR /&gt;
-the data range has to be from Sunday-Saturday&lt;/P&gt;

&lt;P&gt;That means if today is Wednesday, I need to display data from last Sunday up to the current date (Wednesday).&lt;BR /&gt;
And I would need the previous week, i.e, previous Sunday-Saturday and so forth.&lt;BR /&gt;
Here is my current search but it is counting 7 consecutive days:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index001 sourcetype=free_delta          
earliest=-2w@w latest=now              
| timechart span=1w count("duration") AS Total             
| eval period=case(_time&amp;gt;=relative_time(now(),"@w"),"This Week", _time&amp;gt;=relative_time(now(),"-1w@w"),"Prior Week",1=1,"Third Week")              
| table period Total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I change it to filter out from Sunday through Saturday date range? Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 20:47:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239768#M71234</guid>
      <dc:creator>maximusdm</dc:creator>
      <dc:date>2017-01-16T20:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to filter out from Sunday through Saturday date range?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239769#M71235</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index001 sourcetype=free_delta          
 earliest=-2w@w latest=now     
 | eval period=case(_time&amp;gt;=relative_time(now(),"@w"),"This Week", _time&amp;gt;=relative_time(now(),"-1w@w"),"Prior Week",1=1,"Third Week")              
| stats count(duration) as Total by period
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jan 2017 21:49:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239769#M71235</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-16T21:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to filter out from Sunday through Saturday date range?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239770#M71236</link>
      <description>&lt;P&gt;sorry but how are you pulling Sunday-Saturday date range? it still looks like 7 consecutive days. &lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 21:57:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239770#M71236</guid>
      <dc:creator>maximusdm</dc:creator>
      <dc:date>2017-01-16T21:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to filter out from Sunday through Saturday date range?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239771#M71237</link>
      <description>&lt;P&gt;By default the week in Splunk starts from Sunday and ends in Saturday only. Did you check the dates returned by this query and see if they all are sundays??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index001 sourcetype=free_delta          
 earliest=-2w@w latest=now              
 | timechart span=1w count("duration") AS Total    
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jan 2017 22:31:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239771#M71237</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-16T22:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to filter out from Sunday through Saturday date range?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239772#M71238</link>
      <description>&lt;P&gt;yes I see the dates but the example above brings me the data from Sunday the 8th till now. This is what I am trying to do. Giving today's date of 1/17/17 TUESDAY bring me the following data:&lt;BR /&gt;
1/15/17 - 1/17/17 =&amp;gt; This week - Sunday through Tuesday (today's date)&lt;BR /&gt;
1/08/17 - 1/14/17 =&amp;gt; Previous week&lt;BR /&gt;
1/01/17 - 1/07/17 =&amp;gt; The week before previous week&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 19:50:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239772#M71238</guid>
      <dc:creator>maximusdm</dc:creator>
      <dc:date>2017-01-17T19:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to filter out from Sunday through Saturday date range?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239773#M71239</link>
      <description>&lt;P&gt;That doesn't seems right. If I ran a query like this on my Splunk, I get three rows with following dates. Each date is the sunday and give count of events for that week from Sunday to Saturday. So above query should work fine. What's the output you get??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Search: index=_internal sourcetype=splunkd earliest=-2w@w | timechart span=1w count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result&lt;BR /&gt;
_time   count&lt;BR /&gt;
2017-01-01  X&lt;BR /&gt;
2017-01-08  Y&lt;BR /&gt;
2017-01-15  Z&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 20:26:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239773#M71239</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-17T20:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to filter out from Sunday through Saturday date range?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239774#M71240</link>
      <description>&lt;P&gt;If I run these individually I get the right dates for the 3 different periods:&lt;BR /&gt;
earliest=-2w@w latest=@1w&lt;BR /&gt;
earliest=-1w@w latest=@w&lt;BR /&gt;
earliest=@w latest=now&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 21:01:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239774#M71240</guid>
      <dc:creator>maximusdm</dc:creator>
      <dc:date>2017-01-17T21:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to filter out from Sunday through Saturday date range?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239775#M71241</link>
      <description>&lt;P&gt;Insert this into your search before you do the timechart -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval MyDay = relative_time(_time,"-0d@d")
 | eval MySun = relative_time(_time,"-0d@w")
 | eval MySat = MySun+518400
 | eval SkipWeekend = case(MyDay==MySun,1,MyDay==MySat,1,true(),0)
 | search SkipWeekend=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Translation of the above code - &lt;BR /&gt;
set MyDay to the epoch time of the day portion of _time&lt;BR /&gt;
set MySun to the epoch time of the current/prior Sunday of _time &lt;BR /&gt;
set MySat to the epoch time of the Saturday which follows MySun.  (518400 is the number of seconds in six days.)&lt;BR /&gt;
set SkipWeekend to 1 if MyDay is either MySat or MySun&lt;BR /&gt;
search for events where SkipWeekend is 0&lt;/P&gt;

&lt;P&gt;The above code will work even if you plan your weeks to be Monday thru Sunday -- or even Wednesday thru Tuesday -- because regardless of what fiscal week a day might be in, it's still a Saturday.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 21:51:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-filter-out-from-Sunday-through-Saturday/m-p/239775#M71241</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-01-17T21:51:42Z</dc:date>
    </item>
  </channel>
</rss>

