<?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: Why is time chart with span of 1w always Thursday to Thursday? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363841#M107402</link>
    <description>&lt;P&gt;OK, so come back here and either post your own answer or click &lt;CODE&gt;Accept&lt;/CODE&gt; on an existing one to close the question.  Maybe &lt;CODE&gt;UpVote&lt;/CODE&gt; around, too.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Mar 2019 13:59:45 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-03-15T13:59:45Z</dc:date>
    <item>
      <title>Why is time chart with span of 1w always Thursday to Thursday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363836#M107397</link>
      <description>&lt;P&gt;Title pretty much says it all. Every time I go to run a time chart with a span of 1 week it runs from Thursday to Thursday. Is there a specific reason for this? I have a work around for it in most situations (one exception right now being counts by event types), but my gosh its annoying. &lt;/P&gt;

&lt;P&gt;Is there a setting somewhere to control this behavior? &lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 20:24:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363836#M107397</guid>
      <dc:creator>mumblingsages</dc:creator>
      <dc:date>2017-08-11T20:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Why is time chart with span of 1w always Thursday to Thursday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363837#M107398</link>
      <description>&lt;P&gt;TL:DR;&lt;/P&gt;

&lt;P&gt;...or you could do this to also start on a Sunday. (use "@w1" for Monday, "@w2" for Tuesday etc)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval _time = relative_time(_time,"@w")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;That's somewhat inconsistent, relative to the "@w" convention. &lt;/P&gt;

&lt;P&gt;First,  in a normal search, &lt;CODE&gt;bin&lt;/CODE&gt; appears to use info_min_time to determine what day of the week is the first.   That factor seems to affect even searches based on &lt;CODE&gt;gentimes&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;However, if you append something else, the bin for the something else is not necessarily the same, even if the _bin appears in the search after the various appends have occurred.&lt;/P&gt;

&lt;P&gt;Second, because the first day in the universe (1/1/1970)  was a Thursday, this formula will always become a Thursday.  That appears to affect certain kinds of created data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval _time=604800*floor(_time/604800)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want a different day, then do this, where 4 is the number of days earlier in the week you want to move.  Four days before Thursday is Sunday, so this will bin the weeks starting on Sunday.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval _time = -4*86400+604800*floor((_time+4*86400)/604800)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or you could do this to also start on a Sunday. (use "@w1" for Monday, "@w2" for Tuesday etc)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval _time = relative_time(_time,"@w")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... and here's a run-anywhere snippet that you can play with to check what works and what doesn't...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=05/31/16 end=8/1/16 
| eval _time =starttime
| eval time1=strftime(_time,"%Y-%m-%d %a")
| eval time2=strftime(relative_time(_time,"@w"),"%Y-%m-%d %a") 
| bin _time span=1w as time3
| eval time3=strftime(time3,"%Y-%m-%d %a")
| eval _time = -4*86400+604800*floor((_time+4*86400)/604800) 
| stats values(time1) as time1 values(time2) as time2 values(time3) as time3 count by _time 
| eval showtime=strftime(_time,"%Y-%m-%d %a")|
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:21:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363837#M107398</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-09-29T15:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why is time chart with span of 1w always Thursday to Thursday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363838#M107399</link>
      <description>&lt;P&gt;One of these 2 links should give you what you need:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/5350/possible-to-redefine-w-to-start-on-different-day.html"&gt;https://answers.splunk.com/answers/5350/possible-to-redefine-w-to-start-on-different-day.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/208499/how-to-group-events-per-weeknumber.html"&gt;https://answers.splunk.com/answers/208499/how-to-group-events-per-weeknumber.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In your case, I think all that you need to do is add the correct &lt;CODE&gt;w#&lt;/CODE&gt; value to your &lt;CODE&gt;span=1w&lt;/CODE&gt; (e.g. &lt;CODE&gt;span=1w@w0&lt;/CODE&gt; ); see what this does when run for &lt;CODE&gt;Last 7 days&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_*
| multireport [
| bin span=1w@w0 _time
| eval DATASET="w0"
| stats count BY _time DATASET
][
| bin span=1w@w3 _time
| eval DATASET="w1"
| stats count BY _time DATASET
]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Aug 2017 20:58:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363838#M107399</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-11T20:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why is time chart with span of 1w always Thursday to Thursday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363839#M107400</link>
      <description>&lt;P&gt;Thanks both of you.  I had been doing the eval relative time thing. But strangely enough , timechart with a span=1w@w0 is now giving me exactly what I wanted. I swear I've tried this before an it never worked but now is...&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2017 01:26:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363839#M107400</guid>
      <dc:creator>mumblingsages</dc:creator>
      <dc:date>2017-08-12T01:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why is time chart with span of 1w always Thursday to Thursday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363840#M107401</link>
      <description>&lt;P&gt;Try it again tomorrow!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2017 02:17:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363840#M107401</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-12T02:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why is time chart with span of 1w always Thursday to Thursday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363841#M107402</link>
      <description>&lt;P&gt;OK, so come back here and either post your own answer or click &lt;CODE&gt;Accept&lt;/CODE&gt; on an existing one to close the question.  Maybe &lt;CODE&gt;UpVote&lt;/CODE&gt; around, too.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 13:59:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-time-chart-with-span-of-1w-always-Thursday-to-Thursday/m-p/363841#M107402</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-15T13:59:45Z</dc:date>
    </item>
  </channel>
</rss>

