<?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: Set earliest and latest using a variable depending on the current day in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Set-earliest-and-latest-using-a-variable-depending-on-the/m-p/212943#M62396</link>
    <description>&lt;P&gt;Try like this. This will change the earliest and latest (time range) based on today.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source="##" RC="*"  SN="*" [| gentimes start=-1 | eval earliest=if(lower(strftime(now(),"%A"))="monday", "-3d@d-4h", "-1d@d-4h") | eval latest="@d-4h" | table earliest, latest | format "" "" "" "" "" ""] | chart count by  RC, SN
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 26 Sep 2016 13:56:18 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-09-26T13:56:18Z</dc:date>
    <item>
      <title>Set earliest and latest using a variable depending on the current day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-earliest-and-latest-using-a-variable-depending-on-the/m-p/212942#M62395</link>
      <description>&lt;P&gt;Hey,&lt;BR /&gt;
 I want to display the results on a table. it works depending on the timeRange picker when I want it to display results depending on my eval function!!&lt;BR /&gt;
This is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="##" RC="*"  SN="*" [search source="##" | head 1 | eval earliest=if(date_wday="monday", "-3d@d-4h", "-1d@d-4h") | eval latest=if(date_wday="monday", "@d-4h", "@d-4h") | table earliest, latest | format "" "" "" "" "" ""] | chart count by  RC, SN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It doesn't work when It's Monday, I want the search from Friday at 8AM until Monday at 8AM and If it's another day, I want the search results to be from the -d at 8AM until the current day at 8AM.&lt;BR /&gt;
Can you help me, Please?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2016 09:55:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-earliest-and-latest-using-a-variable-depending-on-the/m-p/212942#M62395</guid>
      <dc:creator>sweetlile</dc:creator>
      <dc:date>2016-09-26T09:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Set earliest and latest using a variable depending on the current day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-earliest-and-latest-using-a-variable-depending-on-the/m-p/212943#M62396</link>
      <description>&lt;P&gt;Try like this. This will change the earliest and latest (time range) based on today.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source="##" RC="*"  SN="*" [| gentimes start=-1 | eval earliest=if(lower(strftime(now(),"%A"))="monday", "-3d@d-4h", "-1d@d-4h") | eval latest="@d-4h" | table earliest, latest | format "" "" "" "" "" ""] | chart count by  RC, SN
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Sep 2016 13:56:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-earliest-and-latest-using-a-variable-depending-on-the/m-p/212943#M62396</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-09-26T13:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Set earliest and latest using a variable depending on the current day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-earliest-and-latest-using-a-variable-depending-on-the/m-p/212944#M62397</link>
      <description>&lt;P&gt;Sorry it doen't work I don't know why,&lt;BR /&gt;
this is what I used as a solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="##" RC="*"  SN="*" [search source="##" | head 1 | eval date_wday = strftime(_time, "%A") |eval earliest=if(date_wday="Monday", "-3d@d+8h", "-1d@d+8h") | eval latest=if(date_wday="Monday", "@d+8h", "@d+8h") | table earliest, latest | format "" "" "" "" "" ""] | chart count over RC by SN
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Sep 2016 14:48:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-earliest-and-latest-using-a-variable-depending-on-the/m-p/212944#M62397</guid>
      <dc:creator>sweetlile</dc:creator>
      <dc:date>2016-09-26T14:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Set earliest and latest using a variable depending on the current day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-earliest-and-latest-using-a-variable-depending-on-the/m-p/212945#M62398</link>
      <description>&lt;P&gt;I can see you've changed the earliest and latest calculation, from the one mentioned in the question. Give this a try now..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="##" RC="*"  SN="*" [| gentimes start=-1 | eval earliest=if(lower(strftime(now(),"%A"))="monday", "-3d@d+8h", "-1d@d+8h") | eval latest=if(lower(strftime(now(),"%A"))="monday",  "@d+8h", "@d+8h")   | table earliest, latest | format "" "" "" "" "" ""] | chart count by  RC, SN
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Sep 2016 15:10:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-earliest-and-latest-using-a-variable-depending-on-the/m-p/212945#M62398</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-09-26T15:10:36Z</dc:date>
    </item>
  </channel>
</rss>

