<?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: Compare three date/time ranges in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307146#M92105</link>
    <description>&lt;P&gt;Thanks,&lt;BR /&gt;
The way that i am getting the date1 is by doing earliest(_time) in a stats count.&lt;/P&gt;

&lt;P&gt;From my understanding, this is EPOCH.&lt;/P&gt;

&lt;P&gt;I have tried your query and it doesn't seem to work.&lt;/P&gt;

&lt;P&gt;Any ideaS?&lt;/P&gt;</description>
    <pubDate>Thu, 29 Mar 2018 11:10:58 GMT</pubDate>
    <dc:creator>abbam</dc:creator>
    <dc:date>2018-03-29T11:10:58Z</dc:date>
    <item>
      <title>Compare three date/time ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307142#M92101</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I have three dates which I need to compare, the dates that I have is:&lt;/P&gt;

&lt;P&gt;date1=03/29/2018 04:59:26 #this can be any date/time and changes&lt;BR /&gt;
date2=03/28/2018 12:00:00.000000&lt;BR /&gt;
date3=03/29/2018 12:00:00.000000&lt;/P&gt;

&lt;P&gt;I want to check whether the date1 falls between date2 and date3 - can this be done?&lt;/P&gt;

&lt;P&gt;If date1 falls between date2 AND date3, assign value X, if NOT, assign value Y&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 09:17:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307142#M92101</guid>
      <dc:creator>abbam</dc:creator>
      <dc:date>2018-03-29T09:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Compare three date/time ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307143#M92102</link>
      <description>&lt;P&gt;Assuming your date fields are in string format (as oppose to epoch format), you can try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search which includes field date1 date2 and date3
| eval YourField=if(strptime(date1,"%m/%d/%Y %H:%M:%S")&amp;gt;=strptime(date2,"%m/%d/%Y %H:%M:%S.%6N") AND strptime(date1,"%m/%d/%Y %H:%M:%S")&amp;lt;strptime(date3,"%m/%d/%Y %H:%M:%S.%6N"),"X", "Y")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Mar 2018 09:41:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307143#M92102</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-03-29T09:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Compare three date/time ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307144#M92103</link>
      <description>&lt;P&gt;Hey@abbam,&lt;/P&gt;

&lt;P&gt;Convert your date in epoch time.&lt;BR /&gt;
eval date1_epoch = strptime('date1', "%d/%m/%Y %H:%M:%S") &lt;BR /&gt;
and similarly for other dates and then you can compare the epoch time .&lt;/P&gt;

&lt;P&gt;You can try something like this:&lt;BR /&gt;
eval status=if(date1_epoch&amp;gt;date2_epoch AND date3_epoch&amp;gt;date1_epoch,"X","Y")&lt;/P&gt;

&lt;P&gt;Let me know if this helps!!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:49:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307144#M92103</guid>
      <dc:creator>deepashri_123</dc:creator>
      <dc:date>2020-09-29T18:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Compare three date/time ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307145#M92104</link>
      <description>&lt;P&gt;Please find an example&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
|  eval date1="03/29/2018 04:59:26" 
|  eval date2="03/28/2018 12:00:00.000000" 
|  eval date3="03/29/2018 12:00:00.000000" 
|  eval date1epoch=strptime(date1,"%m/%d/%Y %H:%M:%S") 
|  eval date2epoch=strptime(date2,"%m/%d/%Y %H:%M:%S.%6N") 
|  eval date3epoch=strptime(date3,"%m/%d/%Y %H:%M:%S.%6N") 
|  eval status=if(date1epoch&amp;gt;date2epoch AND date1epoch&amp;lt;date3epoch,"BETWEEN","OUTSIDE")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Mar 2018 09:45:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307145#M92104</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2018-03-29T09:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Compare three date/time ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307146#M92105</link>
      <description>&lt;P&gt;Thanks,&lt;BR /&gt;
The way that i am getting the date1 is by doing earliest(_time) in a stats count.&lt;/P&gt;

&lt;P&gt;From my understanding, this is EPOCH.&lt;/P&gt;

&lt;P&gt;I have tried your query and it doesn't seem to work.&lt;/P&gt;

&lt;P&gt;Any ideaS?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 11:10:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307146#M92105</guid>
      <dc:creator>abbam</dc:creator>
      <dc:date>2018-03-29T11:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Compare three date/time ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307147#M92106</link>
      <description>&lt;P&gt;Thanks, &lt;/P&gt;

&lt;P&gt;The date1 field is from stats earliest(_time).&lt;/P&gt;

&lt;P&gt;The date2 and date3 are from:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval today=relative_time(now(),"@d") 
| eval date2=relative_time(today,"-12h@h")
| eval date3=relative_time(today,"+12h@h")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas how this can work?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 11:24:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307147#M92106</guid>
      <dc:creator>abbam</dc:creator>
      <dc:date>2018-03-29T11:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: Compare three date/time ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307148#M92107</link>
      <description>&lt;P&gt;thanks @deepashri_123&lt;/P&gt;

&lt;P&gt;Thanks, &lt;/P&gt;

&lt;P&gt;The date1 field is from stats earliest(_time).&lt;/P&gt;

&lt;P&gt;The date2 and date3 are from:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval today=relative_time(now(),"@d") 
| eval date2=relative_time(today,"-12h@h")
| eval date3=relative_time(today,"+12h@h")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas how this can work?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 11:25:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307148#M92107</guid>
      <dc:creator>abbam</dc:creator>
      <dc:date>2018-03-29T11:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Compare three date/time ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307149#M92108</link>
      <description>&lt;P&gt;can you try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;       | eval today=relative_time(now(),"@d") 
       | eval date2=relative_time(today,"-12h@h")
       | eval date3=relative_time(today,"+12h@h")  
       |  eval status=if(today&amp;gt;date2 AND today&amp;lt;date3,"BETWEEN","OUTSIDE")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Mar 2018 11:28:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307149#M92108</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-03-29T11:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Compare three date/time ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307150#M92109</link>
      <description>&lt;P&gt;eh.. which Splunk version you running? working for me on 6.4+ versions and works.&lt;/P&gt;

&lt;P&gt;Only reason I can think of is:&lt;BR /&gt;
I've just used your date example format. You might need to change the format in "strptime" accordingly to precise output you are getting in earliest(_time) as it is "locale" driven &lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 14:00:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307150#M92109</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2018-03-29T14:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Compare three date/time ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307151#M92110</link>
      <description>&lt;P&gt;Try this,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval today=relative_time(now(),"@d") 
| eval date2=relative_time(today,"-12h@h") 
| eval date3=relative_time(today,"+12h@h") 
| eval status=case((today&amp;gt;date2 AND today&amp;lt;date3) OR (today&amp;lt;date2 AND today&amp;gt;date3),"BETWEEN",true(),"OUTSIDE")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 14:42:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-three-date-time-ranges/m-p/307151#M92110</guid>
      <dc:creator>TISKAR</dc:creator>
      <dc:date>2018-03-29T14:42:51Z</dc:date>
    </item>
  </channel>
</rss>

