<?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 How do you set date_mday for yesterday? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-set-date-mday-for-yesterday/m-p/439379#M124985</link>
    <description>&lt;P&gt;If I run the following search, adjust the time picker to the last 7 days, AND the 28th falls within the time picker dates,  I get the days counts regardless of what my settings show for my time zone.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index date_mday=28 | stats count as count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, I need to schedule this for yesterday, late in the morning, in order to catch any lagging events from the host. I want to use &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index date_mday=now()-1%d| status count as count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't find an eval command, or any other way, to pass yesterday's %d value to this search.&lt;/P&gt;

&lt;P&gt;Any suggestions? I really need to use the date_mday value for audit purposes. &lt;/P&gt;</description>
    <pubDate>Thu, 31 Jan 2019 21:40:56 GMT</pubDate>
    <dc:creator>dorgra</dc:creator>
    <dc:date>2019-01-31T21:40:56Z</dc:date>
    <item>
      <title>How do you set date_mday for yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-set-date-mday-for-yesterday/m-p/439379#M124985</link>
      <description>&lt;P&gt;If I run the following search, adjust the time picker to the last 7 days, AND the 28th falls within the time picker dates,  I get the days counts regardless of what my settings show for my time zone.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index date_mday=28 | stats count as count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, I need to schedule this for yesterday, late in the morning, in order to catch any lagging events from the host. I want to use &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index date_mday=now()-1%d| status count as count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't find an eval command, or any other way, to pass yesterday's %d value to this search.&lt;/P&gt;

&lt;P&gt;Any suggestions? I really need to use the date_mday value for audit purposes. &lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 21:40:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-set-date-mday-for-yesterday/m-p/439379#M124985</guid>
      <dc:creator>dorgra</dc:creator>
      <dc:date>2019-01-31T21:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do you set date_mday for yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-set-date-mday-for-yesterday/m-p/439380#M124986</link>
      <description>&lt;P&gt;Why is this not good enough (it has the added benefit to work for those events which do not have the &lt;CODE&gt;date_*&lt;/CODE&gt; fields, which are unreliable anyway)?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index earliest=-1d@d latest=@d | stats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In any case, you can do this (which is silly):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index [|makeresults | eval date_mday=strftime(relative_time(now(), "-1d"), "%d")] | stats count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Jan 2019 23:23:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-set-date-mday-for-yesterday/m-p/439380#M124986</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-01-31T23:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do you set date_mday for yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-set-date-mday-for-yesterday/m-p/439381#M124987</link>
      <description>&lt;P&gt;Your answer gives different results depending on the user settings for timezone. Think I mentioned that. Thanks for the answer, but it gives different results and therefore doesn't work for an audit requirement. It took me a while longer than expected, but the correct answer is:&lt;/P&gt;

&lt;P&gt;index=tse001&lt;BR /&gt;
| eval yest=strftime(relative_time(time(), "-d"), "%d")&lt;BR /&gt;
| where date_mday=yest&lt;BR /&gt;
| stats count as count&lt;/P&gt;

&lt;P&gt;If anyone can point out an error in my search, please feel free to post. It is critical to the audit requirement that I get all events sent from the host on that particular day, considering possible lag in indexing and that the search may run from a different timezone. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:02:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-set-date-mday-for-yesterday/m-p/439381#M124987</guid>
      <dc:creator>dorgra</dc:creator>
      <dc:date>2020-09-29T23:02:16Z</dc:date>
    </item>
  </channel>
</rss>

