<?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: How do I search records for today and 120 days back? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485422#M135828</link>
    <description>&lt;P&gt;Now I'm lost.  That last query seems to do something very different from the "120 days ago" in the original question.&lt;/P&gt;</description>
    <pubDate>Fri, 01 May 2020 16:50:28 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-05-01T16:50:28Z</dc:date>
    <item>
      <title>How do I search records for today and 120 days back?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485415#M135821</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;sort -date | dedup Date_Month_Year | where Date&amp;gt;1575183600
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need this query to run only for the past 120 days from today.  I can put in the date manually as above, but need this to be more automated so anyone can run this query and get results for the current to 120 day range.  &lt;/P&gt;

&lt;P&gt;I have the following fields:&lt;BR /&gt;
&lt;STRONG&gt;Date              Date_Friendly   Date_Month_Year   Host_Count&lt;BR /&gt;
15786200   01/01/2020         January 2020           1234&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I have tried 2 things and neither works.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;where (strptime(Date, "%m/%d/%Y")&amp;gt;=strptime("4/2/2018", "%m/%d/%Y")) AND (strptime(Date, "%m/%d/%Y")&amp;gt;=strptime("4/10/2018", "%m/%d/%Y"))&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Date="1/1/2020" 
| eval timestampDate=strptime(Date, "%m/%d/%Y")  
| eval timestampStart=strptime("1/1/2020", "%m/%d/%Y") 
| eval timestampEnd=strptime("5/1/2020", "%m/%d/%Y") 
| eval formattedTimestamp = strftime(timestamp,"%Y-%m-%dT%H:%M:%S") 
| where timestampDate &amp;gt;= timestampStart AND timestampDate &amp;lt;= timestampEnd
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:11:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485415#M135821</guid>
      <dc:creator>tferranteku</dc:creator>
      <dc:date>2020-09-30T05:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search records for today and 120 days back?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485416#M135822</link>
      <description>&lt;P&gt;Assuming your events have _time in them, besides the fields you already have, can you try this really quick?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... &amp;lt;whatever searches you have&amp;gt;
earliest =-120d@d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest="01/01/2020:00:00:00" 
latest="05/01/2020:00:00:00" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Either should work.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 22:13:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485416#M135822</guid>
      <dc:creator>tauliang</dc:creator>
      <dc:date>2020-04-30T22:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search records for today and 120 days back?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485417#M135823</link>
      <description>&lt;P&gt;Try &lt;CODE&gt;relative_time&lt;/CODE&gt;.  It computes a new timestamp based on an existing time and a modifier string.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;where (strptime(Date, "%m/%d/%Y")&amp;gt;=relative_time(now(), "-120d"))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 May 2020 12:51:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485417#M135823</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-01T12:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search records for today and 120 days back?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485418#M135824</link>
      <description>&lt;P&gt;I am getting Unknown search command 'earliest'&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 14:15:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485418#M135824</guid>
      <dc:creator>tferranteku</dc:creator>
      <dc:date>2020-05-01T14:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search records for today and 120 days back?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485419#M135825</link>
      <description>&lt;P&gt;Received the following error:&lt;BR /&gt;
Error in 'where' command: The expression is malformed. Expected).&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 14:19:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485419#M135825</guid>
      <dc:creator>tferranteku</dc:creator>
      <dc:date>2020-05-01T14:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search records for today and 120 days back?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485420#M135826</link>
      <description>&lt;P&gt;So add the missing &lt;CODE&gt;)&lt;/CODE&gt;.  See the updated answer.&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 15:40:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485420#M135826</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-01T15:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search records for today and 120 days back?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485421#M135827</link>
      <description>&lt;P&gt;You are correct that I was missing the ) -- but now i get No results found.&lt;/P&gt;

&lt;P&gt;This is what i have so far that works but I need to simplify:&lt;/P&gt;

&lt;P&gt;sort -date | dedup Date_Month_Year | where Date_Friendly="05/01/2020" or Date_Friendly="04/01/2020" or Date_Friendly="03/01/2020" &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:17:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485421#M135827</guid>
      <dc:creator>tferranteku</dc:creator>
      <dc:date>2020-09-30T05:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search records for today and 120 days back?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485422#M135828</link>
      <description>&lt;P&gt;Now I'm lost.  That last query seems to do something very different from the "120 days ago" in the original question.&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 16:50:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485422#M135828</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-01T16:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search records for today and 120 days back?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485423#M135829</link>
      <description>&lt;P&gt;I worked out my answer:&lt;/P&gt;

&lt;P&gt;dedup Date_Month_Year _ | Sort Date | eval Range=now() | eval StartRange=(Range-10518972) | where Date&amp;gt;StartRange&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:17:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-records-for-today-and-120-days-back/m-p/485423#M135829</guid>
      <dc:creator>tferranteku</dc:creator>
      <dc:date>2020-09-30T05:17:06Z</dc:date>
    </item>
  </channel>
</rss>

