<?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: modify date of search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376863#M170394</link>
    <description>&lt;P&gt;First of all, be aware that you can set your personal timezone in &lt;CODE&gt;&amp;lt;Your Name&amp;gt;&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Preferences&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Time zone&lt;/CODE&gt; and then you can avoid all of your &lt;CODE&gt;strftime&lt;/CODE&gt; stuff; try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=en_amp_api earliest=@w1 latest=@w2
| eval week=case(
   last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"), "week1",
   last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"), "week2",
   last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"), "week3",
   last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"), "week4",
   true(), "other")
| stats count BY week
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 11 Jul 2019 15:02:26 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-07-11T15:02:26Z</dc:date>
    <item>
      <title>modify date of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376859#M170390</link>
      <description>&lt;P&gt;how to modify time after a search, for example i search something on thirst day of week (08 date) and after i would like to search on last week first day (01 date) all this search is in one search.  In classic programming i will be use for loop&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 12:17:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376859#M170390</guid>
      <dc:creator>cipi23</dc:creator>
      <dc:date>2019-07-11T12:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: modify date of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376860#M170391</link>
      <description>&lt;P&gt;You can specify &lt;CODE&gt;search (earliest=x latest=y) OR (earliest=w latest=z)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 12:45:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376860#M170391</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2019-07-11T12:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: modify date of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376861#M170392</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=en_amp_api
 earliest=@w1 latest=@w2
| eval description1=case(last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"),"week1")
| eval description2=case(last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"),"week2")
| eval description3=case(last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"),"week3")
| eval description4=case(last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"),"week4")
| stats count(description1) as week1,count(description2) as week2,count(description3) as week3,count(description4) as week4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this is my code and i would like to modify earliest and latest for each case&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 12:51:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376861#M170392</guid>
      <dc:creator>cipi23</dc:creator>
      <dc:date>2019-07-11T12:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: modify date of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376862#M170393</link>
      <description>&lt;P&gt;either you're willing to run 4 searches, one for each week, which can be done like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval earliest=&amp;lt;week2_begins&amp;gt;, latest=&amp;lt;week1_ends&amp;gt;, weeknumber=1
| append [ | makeresults | eval earliest=&amp;lt;week2_begins&amp;gt;, latest=&amp;lt;week2_ends&amp;gt;, weeknumber=2 ]
| append [ | makeresults | eval earliest=&amp;lt;week3_begins&amp;gt;, latest=&amp;lt;week3_ends&amp;gt;,weeknumber=3 ]
| append [ | makeresults | eval earliest=&amp;lt;week4_begins&amp;gt;, latest=&amp;lt;week4_ends&amp;gt;, weeknumber=4 ]
| map search="search  index=en_amp_api  earliest=$earliest$ latest=$latest$ | eval description=$weeknumber$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or you specify earliest and latest that includes all the 4 weeks&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;yourindex&amp;gt; earliest=&amp;lt;week1_begins&amp;gt; latest=&amp;lt;week4_ends&amp;gt;  | stats sum(eval(if(last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"),1,0))) as "week1", sum(eval(if(strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ")&amp;lt;last_seen AND last_seen&amp;lt;strftime(relative_time(_time,"-3w"),"%Y-%m-%dT%H:%M:%SZ"),1,0))) as "week2"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jul 2019 13:04:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376862#M170393</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2019-07-11T13:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: modify date of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376863#M170394</link>
      <description>&lt;P&gt;First of all, be aware that you can set your personal timezone in &lt;CODE&gt;&amp;lt;Your Name&amp;gt;&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Preferences&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Time zone&lt;/CODE&gt; and then you can avoid all of your &lt;CODE&gt;strftime&lt;/CODE&gt; stuff; try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=en_amp_api earliest=@w1 latest=@w2
| eval week=case(
   last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"), "week1",
   last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"), "week2",
   last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"), "week3",
   last_seen&amp;lt;strftime(relative_time(_time,"-4w"),"%Y-%m-%dT%H:%M:%SZ"), "week4",
   true(), "other")
| stats count BY week
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jul 2019 15:02:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376863#M170394</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-11T15:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: modify date of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376864#M170395</link>
      <description>&lt;P&gt;First of all, be aware that you can set your personal timezone in &lt;CODE&gt;&amp;lt;Your Name&amp;gt;&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Preferences&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Time zone&lt;/CODE&gt; and then you can avoid all of your &lt;CODE&gt;strftime&lt;/CODE&gt; stuff; if you do that, then this should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=en_amp_api earliest=@w1 latest=@w2
| timechart span=1w count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jul 2019 15:03:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376864#M170395</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-11T15:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: modify date of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376865#M170396</link>
      <description>&lt;P&gt;i have to display count of hosnames, that have last_seen &amp;gt;30 days, in first day of week:&lt;/P&gt;

&lt;P&gt;for 08.07.19 count number of hostnames that have last_seen &amp;gt;30 days&lt;BR /&gt;
for 01.07.19 count number of hostnames that have last_seen &amp;gt;30 days&lt;BR /&gt;
for 24.06.19 count number of hostnames that have last_seen &amp;gt;30 days&lt;BR /&gt;
for 17.06.19 count number of hostnames that have last_seen &amp;gt;30 days&lt;/P&gt;

&lt;P&gt;the output will be:&lt;BR /&gt;
week1     count&lt;BR /&gt;
week2     count&lt;BR /&gt;
week3     count&lt;BR /&gt;
week4     count&lt;/P&gt;

&lt;P&gt;all this i need to do in one search&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:18:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/modify-date-of-search/m-p/376865#M170396</guid>
      <dc:creator>cipi23</dc:creator>
      <dc:date>2020-09-30T01:18:07Z</dc:date>
    </item>
  </channel>
</rss>

