<?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: Get data from the last 2 business days in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Get-data-from-the-last-2-business-days/m-p/539820#M152688</link>
    <description>&lt;P&gt;Also to note that there must be events on the "last working day" for this search to work.&lt;/P&gt;</description>
    <pubDate>Sun, 14 Feb 2021 00:25:48 GMT</pubDate>
    <dc:creator>lydiapal_splunk</dc:creator>
    <dc:date>2021-02-14T00:25:48Z</dc:date>
    <item>
      <title>Get data from the last 2 business days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-data-from-the-last-2-business-days/m-p/539517#M152580</link>
      <description>&lt;P&gt;I'm setting an alert that will run everdy business day at 9AM and triggers only if the sum of a field is 0 for 2 consecutive business day.&lt;BR /&gt;&lt;BR /&gt;To do that, I&amp;nbsp;want to set my time range for my search to return events from the last two business days.&lt;/P&gt;&lt;P&gt;For example, if it is Monday, it will return data for Thursday and Friday, if it is Tuesday, it will return data for Friday and Monday.&lt;/P&gt;&lt;P&gt;I tried to use "earliest" and "latest" at the beginning of my search&amp;nbsp; but I can't get it to work....&lt;BR /&gt;&lt;BR /&gt;Any Help would be welcome ! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 16:26:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-data-from-the-last-2-business-days/m-p/539517#M152580</guid>
      <dc:creator>younesboumaaz</dc:creator>
      <dc:date>2021-02-11T16:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Get data from the last 2 business days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-data-from-the-last-2-business-days/m-p/539819#M152687</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a solution that will work if your data has the default field "date_wday" extracted (see docs &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/latest/Knowledge/Usedefaultfields" target="_self"&gt;here&lt;/A&gt;). Although it is a default field (extracted automatically), you should read the docs before using this field. If this field is not available, you would need some other logic to determine the weekday for each event.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=yourindex earliest=-4d@d latest=-0d@d date_wday IN ("monday","tuesday","wednesday","thursday","friday")
| eventstats latest(date_wday) as last_weekday
| eval previous_working_day=case(last_weekday="monday","friday",last_weekday="tuesday","monday",last_weekday="wednesday","tuesday",last_weekday="thursday","wednesday",last_weekday="friday","thursday")
| where date_wday=last_weekday OR date_wday=previous_working_day
... rest of your search...&lt;/LI-CODE&gt;&lt;P&gt;Basically the search will look back last 4 full days (as on Monday it will have to look back for Thursday-Friday).&lt;/P&gt;&lt;P&gt;It will filter to only look at weekdays, determine last week day, and based on this, determine the previous week day. Then it will filter to only show those last two weekdays.&lt;/P&gt;&lt;P&gt;Hope this helps!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Phoebe&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 00:24:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-data-from-the-last-2-business-days/m-p/539819#M152687</guid>
      <dc:creator>lydiapal_splunk</dc:creator>
      <dc:date>2021-02-14T00:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get data from the last 2 business days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-data-from-the-last-2-business-days/m-p/539820#M152688</link>
      <description>&lt;P&gt;Also to note that there must be events on the "last working day" for this search to work.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 00:25:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-data-from-the-last-2-business-days/m-p/539820#M152688</guid>
      <dc:creator>lydiapal_splunk</dc:creator>
      <dc:date>2021-02-14T00:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get data from the last 2 business days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-data-from-the-last-2-business-days/m-p/539954#M152736</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you for your response! Indeed, it would work if only date_wday was in my data... But no worries, it inspired me, and I worked on it to finally find a solution!&lt;BR /&gt;&lt;BR /&gt;I've set my time range to "6 last days" :&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=yourindex
| timechart span=1d sum(NbrHashOK) as sommehash 
| fillnull value=0 sommehash 
| eval 
Jour=strftime(_time, "%A %d %B %Y"),
day_of_week = strftime(_time,"%A"),
now=strftime(now(),"%A") , 
test=case(now="Monday" AND (day_of_week="Thursday" OR day_of_week="Friday"),"OK",
now="Tuesday" AND (day_of_week="Friday" OR day_of_week="Monday"),"OK",
now="Wednesday" AND (day_of_week="Monday" OR day_of_week="Tuesday"),"OK",
now="Thursday" AND (day_of_week="Tuesday" OR day_of_week="Wednesday"),"OK",
now="Friday" AND (day_of_week="Wednesday" OR day_of_week="Thursday"),"OK",
1=1,0) 
| where test="OK" 
| stats sum(sommehash) as test_sommehash values(Jour) as jour&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 13:35:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-data-from-the-last-2-business-days/m-p/539954#M152736</guid>
      <dc:creator>younesboumaaz</dc:creator>
      <dc:date>2021-02-15T13:35:13Z</dc:date>
    </item>
  </channel>
</rss>

