<?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: latest date in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352435#M162341</link>
    <description>&lt;P&gt;it's work for the last week ut dont for the last month for exemple or for yesterday&lt;BR /&gt;
Tis is what i have for yesterday on the search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |eval date = strftime(_time,"%Y-%m-%d") 
  | eval earliest_time_relative=relative_time(now(),"-1d@d")
  | eval earliest_time = strftime(earliest_time_relative,"%Y-%m-%d")
  | eval latest_time_relative=relative_time(now(),"true")
  | eval latest_time = strftime(latest_time_relative,"%Y-%m-%d")
  | where (_time &amp;gt;= earliest_time_relative AND _time&amp;lt;=latest_time_relative) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 14 Mar 2018 16:02:05 GMT</pubDate>
    <dc:creator>taha13</dc:creator>
    <dc:date>2018-03-14T16:02:05Z</dc:date>
    <item>
      <title>latest date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352429#M162335</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;

&lt;P&gt;So my question today is: for my earliest time i have "-1w@w1",so my research start from the last monday.The problem is despite the latest time is "-0w@w",i have yesterday as latest time . While i want the last saturday as latest time&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |eval date_time = strftime(_time,"%Y-%m-%d") 
              | eval earliest_time_relative=relative_time(now(),"-1w@w1")
                | eval earliest_time = strftime(earliest_time_relative,"%Y-%m-%d")

                | eval earliest1_time_relative=relative_time(now(),"-1w@w1")
                | eval earliest1_time = strftime(earliest1_time_relative,"%Y-%m-%d")

                | eval latest_time_relative=relative_time(now(),"-0w@w")
                | eval latest_time = strftime(latest_time_relative,"%Y-%m-%d")

                | eval date = strftime(_time,"%Y-%m-%d")
                | where date == "-1w@w" OR (date_time &amp;gt;= earliest1_time AND latest_time &amp;gt;= date_time) OR date_time&amp;gt;= earliest_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4546i02D6D06A3B6B89A8/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 10:44:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352429#M162335</guid>
      <dc:creator>taha13</dc:creator>
      <dc:date>2018-03-14T10:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: latest date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352430#M162336</link>
      <description>&lt;P&gt;your &lt;CODE&gt;earliest_time&lt;/CODE&gt;-type and &lt;CODE&gt;latest_time&lt;/CODE&gt;-type fields are not in an epoch form, they are strings. because of that, you cannot filter using &lt;CODE&gt;_time&lt;/CODE&gt; . I'm also not sure why you have two sets for earliest that are calculating the same thing. try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval date = strftime(_time,"%Y-%m-%d") 
 | eval earliest_time_relative=relative_time(now(),"-1w@w1")
 | eval earliest_time = strftime(earliest_time_relative,"%Y-%m-%d")
 | eval latest_time_relative=relative_time(now(),"@w6")
 | eval latest_time = strftime(latest_time_relative,"%Y-%m-%d")
 | where (_time &amp;gt;= earliest_time_relative AND _time&amp;lt;=latest_time_relative) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;some of the evals might not be necessary. i'm not using &lt;CODE&gt;date&lt;/CODE&gt;,&lt;CODE&gt;earliest_time&lt;/CODE&gt;, or &lt;CODE&gt;latest_time&lt;/CODE&gt;. depending on what you're doing, you could also just put &lt;CODE&gt;earliest=1w@w1 latest=@w6&lt;/CODE&gt; in the base search instead of doing this eval. &lt;/P&gt;

&lt;P&gt;if this isn't what you're looking for, please let me know what i'm missing so i can better help.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 11:49:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352430#M162336</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2018-03-14T11:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: latest date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352431#M162337</link>
      <description>&lt;P&gt;It's doesnt work,this is my code &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    |eval date_time = strftime(_time,"%Y-%m-%d") 
              | eval earliest_time_relative=relative_time(now(),"$earliest_token$")
                | eval earliest_time = strftime(earliest_time_relative,"%Y-%m-%d")

                | eval earliest1_time_relative=relative_time(now(),"$earliest1_token$")
                | eval earliest1_time = strftime(earliest1_time_relative,"%Y-%m-%d")

                | eval latest_time_relative=relative_time(now(),"$latest_token$")
                | eval latest_time = strftime(latest_time_relative,"%Y-%m-%d")

                | eval date = strftime(_time,"%Y-%m-%d")
                | where date == "$time_token$" OR (date_time &amp;amp;gt;= earliest1_time AND latest_time &amp;amp;gt;= date_time) OR date_time&amp;amp;gt;= earliest_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then when i read the serch i have :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  |eval date = strftime(_time,"%Y-%m-%d") 
  | eval earliest_time_relative=relative_time(now(),"-1d@d")
  | eval earliest_time = strftime(earliest_time_relative,"%Y-%m-%d")

  | eval latest_time_relative=relative_time(now(),"true")
  | eval latest_time = strftime(latest_time_relative,"%Y-%m-%d")
  | where date == (_time &amp;gt;= earliest_time AND latest_time_relative &amp;gt;= _time) OR _time &amp;gt;= earliest_time_relative
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 12:42:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352431#M162337</guid>
      <dc:creator>taha13</dc:creator>
      <dc:date>2018-03-14T12:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: latest date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352432#M162338</link>
      <description>&lt;P&gt;what are you inputting for your latest_time that it is evaluating to &lt;EM&gt;true&lt;/EM&gt; &lt;/P&gt;

&lt;P&gt;can you post what your inputs look like? you have &lt;CODE&gt;$time_token$&lt;/CODE&gt;, but i'm not sure how that's being created, so unless it's in the form of &lt;EM&gt;YYYY-MM-DD&lt;/EM&gt;, that part of your &lt;CODE&gt;where&lt;/CODE&gt; statement won't work. the &lt;CODE&gt;date_time&amp;gt;=earliest_time&lt;/CODE&gt; won't work either, since that is a string and not epoch. maybe try &lt;CODE&gt;|eval date_time = strptime(strftime(_time,"%Y-%m-%d") ,"%Y-%m-%d")&lt;/CODE&gt; or even &lt;CODE&gt;|eval date_time=relative_time(_time,"@d")&lt;/CODE&gt; to snap &lt;CODE&gt;_time&lt;/CODE&gt; to the beginning of the day, which is essentially what you're doing with &lt;CODE&gt;strftime&lt;/CODE&gt;. &lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 14:01:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352432#M162338</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2018-03-14T14:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: latest date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352433#M162339</link>
      <description>&lt;P&gt;My input :    &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;          &amp;lt;set token="earliest1_token"&amp;gt;-1w@w1&amp;lt;/set&amp;gt;
          &amp;lt;set token="earliest_token"&amp;gt;-1w@w1&amp;lt;/set&amp;gt;
          &amp;lt;set token="latest_token"&amp;gt;@w6&amp;lt;/set&amp;gt;
          &amp;lt;set token="time_token"&amp;gt;true&amp;lt;/set&amp;gt;
          &amp;lt;unset token="depends_token_1"&amp;gt;true&amp;lt;/unset&amp;gt;
          &amp;lt;unset token="depends_token_2"&amp;gt;true&amp;lt;/unset&amp;gt;
          &amp;lt;unset token="depends_token_3"&amp;gt;true&amp;lt;/unset&amp;gt;
          &amp;lt;unset token="depends_token_4"&amp;gt;true&amp;lt;/unset&amp;gt;
          &amp;lt;unset token="depends_token_5"&amp;gt;true&amp;lt;/unset&amp;gt;
          &amp;lt;unset token="depends_token_6"&amp;gt;true&amp;lt;/unset&amp;gt;
          &amp;lt;set token="depends_token_7"&amp;gt;true&amp;lt;/set&amp;gt;
          &amp;lt;unset token="depends_token_8"&amp;gt;true&amp;lt;/unset&amp;gt;
          &amp;lt;unset token="depends_token_9"&amp;gt;true&amp;lt;/unset&amp;gt;
          &amp;lt;set token="show_Data_Labels_token"&amp;gt;all&amp;lt;/set&amp;gt;
          &amp;lt;set token="token_span"&amp;gt;$token_span7$&amp;lt;/set&amp;gt;
          &amp;lt;!-- &amp;lt;set token="loadjob_token_job"&amp;gt;job_mois_encours&amp;lt;/set&amp;gt; --&amp;gt;
          &amp;lt;set token="loadjob_token_job"&amp;gt;job_mois_encours_backup&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 14:10:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352433#M162339</guid>
      <dc:creator>taha13</dc:creator>
      <dc:date>2018-03-14T14:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: latest date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352434#M162340</link>
      <description>&lt;P&gt;taha13,&lt;/P&gt;

&lt;P&gt;Can you make this work in an actual search?  I think that's your first step.  &lt;/P&gt;

&lt;P&gt;Be sure to use the epoch versions of the dates/times, because that's what _time is.  E.g. in all the above, do NOT use the "earliest_time" and so on, but instead use the "earliest_time_relative" and related fields for your comparisons.&lt;/P&gt;

&lt;P&gt;Once you get it working in a search and returning only the days you want, I think it'll be pretty easy to make it work in your dashboard.&lt;/P&gt;

&lt;P&gt;Or can you post the entire search? Maybe there's something going on there we aren't seeing?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:26:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352434#M162340</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2020-09-29T18:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: latest date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352435#M162341</link>
      <description>&lt;P&gt;it's work for the last week ut dont for the last month for exemple or for yesterday&lt;BR /&gt;
Tis is what i have for yesterday on the search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |eval date = strftime(_time,"%Y-%m-%d") 
  | eval earliest_time_relative=relative_time(now(),"-1d@d")
  | eval earliest_time = strftime(earliest_time_relative,"%Y-%m-%d")
  | eval latest_time_relative=relative_time(now(),"true")
  | eval latest_time = strftime(latest_time_relative,"%Y-%m-%d")
  | where (_time &amp;gt;= earliest_time_relative AND _time&amp;lt;=latest_time_relative) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 16:02:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352435#M162341</guid>
      <dc:creator>taha13</dc:creator>
      <dc:date>2018-03-14T16:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: latest date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352436#M162342</link>
      <description>&lt;P&gt;I think @cmerriman asked this too, but how could &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval latest_time_relative=relative_time(now(),"true")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;possibly work?&lt;/P&gt;

&lt;P&gt;If you run the search and replace &lt;CODE&gt;true&lt;/CODE&gt; with what you want the latest time to be, does that search run and give you the desired results?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 16:05:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/latest-date/m-p/352436#M162342</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2018-03-14T16:05:00Z</dc:date>
    </item>
  </channel>
</rss>

