<?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: Can you help me with relative time conditions? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385023#M173815</link>
    <description>&lt;P&gt;I want to display only the host which have been loggend since less than 2 days and which have not rebooted since more 10 days&lt;BR /&gt;
you can see the result here&lt;BR /&gt;
&lt;A href="https://cjoint.com/c/IAejdxWgnFd"&gt;https://cjoint.com/c/IAejdxWgnFd&lt;/A&gt; &lt;/P&gt;</description>
    <pubDate>Fri, 04 Jan 2019 09:04:26 GMT</pubDate>
    <dc:creator>jip31</dc:creator>
    <dc:date>2019-01-04T09:04:26Z</dc:date>
    <item>
      <title>Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385014#M173806</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;

&lt;P&gt;I use this request, but I am not sure it works fine.&lt;/P&gt;

&lt;P&gt;In the query below, I want to display the LastLogon and LastReboot fields from the following date conditions:&lt;/P&gt;

&lt;P&gt;I just want to display a result if LastLogon &amp;lt; 2 days from the current day and if LastReboot &amp;gt;10 days from the current day.&lt;/P&gt;

&lt;P&gt;But, when I play with the relative time values, it doesn't return the corresponding event.&lt;/P&gt;

&lt;P&gt;For example, we are the 3rd of January.&lt;/P&gt;

&lt;P&gt;Normally  &lt;CODE&gt;| eval secondlastday=relative_time(now(), "-2d@d"&lt;/CODE&gt; should return me values between the 1st and the 3rd of January, but it also returns the oldest values:&lt;/P&gt;

&lt;P&gt;Could you help me please??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="windows-wmi-fr" (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") 
| eval LastLogon = strftime(strptime(LastLogon,"%Y%m%d%H%M%S"),"%d/%m/%Y %H:%M") 
| rex field=LastLogon mode=sed "s/..$//" 
| eval LastBootUpTime = strftime(strptime(LastBootUpTime,"%Y%m%d%H%M%S"),"%d/%m/%Y %H:%M") 
| rex field=LastBootUpTime mode=sed "s/..$//" 
| eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S")
| eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S")
| eval secondlastday=relative_time(now(), "-2d@d")
| eval nexttendays=relative_time(now(), "10d@d")
 | where (LastLogon &amp;lt;secondlastday) AND (LastBootUpTime &amp;gt;nexttendays)
|stats latest(LastLogon) as LastLogon, latest(LastBootUpTime) as LastReboot by host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Jan 2019 15:19:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385014#M173806</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-01-03T15:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385015#M173807</link>
      <description>&lt;P&gt;Try this&lt;BR /&gt;
     index="windows-wmi-fr" (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") &lt;BR /&gt;
     | eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S")&lt;BR /&gt;
     | eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S") &lt;BR /&gt;
     | eval secondlastday=relative_time(now(), "-2d@d")&lt;BR /&gt;
     | eval nexttendays=relative_time(now(), "10d@d") &lt;BR /&gt;
     | where (LastLogon &amp;lt; secondlastday) AND (LastBootUpTime &amp;gt; nexttendays) ...&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:33:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385015#M173807</guid>
      <dc:creator>andreacorvini</dc:creator>
      <dc:date>2020-09-29T22:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385016#M173808</link>
      <description>&lt;P&gt;I have no error but also no results even if I change relative time&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 07:14:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385016#M173808</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-01-04T07:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385017#M173809</link>
      <description>&lt;P&gt;I think now the issue is related to the eval.&lt;BR /&gt;
I don't know what you want but you are not populating nexttendays with nexttendays=relative_time(now(), "10d@d").&lt;BR /&gt;
If you try with nexttendays=relative_time(now(), "-10d@d") you will have results I think but I don't know if it's the result you required.&lt;BR /&gt;
So try to check variables with this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval nexttendays=relative_time(now(), "-10d@d") | eval secondlastday=relative_time(now(), "-2d@d") | table nexttendays secondlastday
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:39:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385017#M173809</guid>
      <dc:creator>andreacorvini</dc:creator>
      <dc:date>2020-09-29T22:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385018#M173810</link>
      <description>&lt;P&gt;no it doesnt works&lt;BR /&gt;
if I just do this I have results but not in the date format&lt;BR /&gt;
just : 1543420093.000000 &lt;BR /&gt;
&lt;CODE&gt;index="ai-wkst-windows-wmi-fr"  (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") &lt;BR /&gt;
 | eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S")&lt;BR /&gt;
 | eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S") &lt;BR /&gt;
 | eval secondlastday=relative_time(now(), "-2d@d")&lt;BR /&gt;
 | eval nexttendays=relative_time(now(), "10d@d") &lt;BR /&gt;
 | where (LastLogon &amp;lt; secondlastday) | table LastLogon&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 07:28:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385018#M173810</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-01-04T07:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385019#M173811</link>
      <description>&lt;P&gt;I think it will be correct with "-10d@d"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ai-wkst-windows-wmi-fr" (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") | eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S") | eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S") | eval secondlastday=relative_time(now(), "-2d@d") | eval nexttendays=relative_time(now(), "-10d@d") | where (LastLogon &amp;lt; secondlastday) | table LastLogon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;anyway please run &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index="ai-wkst-windows-wmi-fr" (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") | eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S") | eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S") | eval secondlastday=relative_time(now(), "-2d@d") | eval nexttendays=relative_time(now(), "-10d@d")| table LastLogon LastBootUpTime secondlastday nexttendays
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1543420093.000000 is correct, it's the epoch time to compare. I use &lt;A href="https://www.epochconverter.com/"&gt;epochconverter&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 07:35:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385019#M173811</guid>
      <dc:creator>andreacorvini</dc:creator>
      <dc:date>2019-01-04T07:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385020#M173812</link>
      <description>&lt;P&gt;...and pay attention that if you want to use &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval nexttendays=relative_time(now(), "10d@d") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you have to use "+"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval nexttendays=relative_time(now(), "+10d@d") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but in this case you'll have a result date in the future.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 08:33:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385020#M173812</guid>
      <dc:creator>andreacorvini</dc:creator>
      <dc:date>2019-01-04T08:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385021#M173813</link>
      <description>&lt;P&gt;I confirm that with -10d@d it doesnt works&lt;BR /&gt;
    index="ai-wkst-windows-wmi-fr" (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") | eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S") | eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S") | eval secondlastday=relative_time(now(), "-2d@d") | eval nexttendays=relative_time(now(), "-10d@d")  | where (LastLogon &amp;lt; secondlastday) AND (LastBootUpTime &amp;gt; nexttendays)  | table LastLogon LastBootUpTime&lt;/P&gt;

&lt;P&gt;and I just want to display a result if LastLogon &amp;lt; 2 days from the current day and if LastReboot &amp;gt;10 days from the current day.&lt;/P&gt;

&lt;P&gt;when i do the code below i have results but I need to add my where conditions&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ai-wkst-windows-wmi-fr" (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") 
| eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S") 
| eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S") 
| eval secondlastday=relative_time(now(), "-2d@d") 
| eval nexttendays=relative_time(now(), "10d@d") 
| dedup host 
| table host LastLogon LastBootUpTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So if i do this I have results&lt;BR /&gt;
but whenever I add AND (LastBootUpTime &amp;gt; nexttendays) i have no results even if I modifiy the relative time!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ai-wkst-windows-wmi-fr" (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") 
| eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S") 
| eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S") 
| eval secondlastday=relative_time(now(), "-2d@d") 
| eval nexttendays=relative_time(now(), "10d@d") 
| dedup host 
| where (LastLogon &amp;lt; secondlastday)
| table host LastLogon LastBootUpTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:34:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385021#M173813</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2020-09-29T22:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385022#M173814</link>
      <description>&lt;P&gt;... "and I just want to display a result if LastLogon &amp;lt; 2 days from the current day and if LastReboot &amp;gt;10 days from the current day."&lt;/P&gt;

&lt;P&gt;you mean the last reboot executed in the last 10 days?&lt;BR /&gt;
Or executed more than 10 days ago?&lt;BR /&gt;
Please run the query I wrote and share (an example) the event you want to view.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ai-wkst-windows-wmi-fr" (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") | eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S") | eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S") | eval secondlastday=relative_time(now(), "-2d@d") | eval nexttendays=relative_time(now(), "-10d@d")| table LastLogon LastBootUpTime secondlastday nexttendays
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Jan 2019 08:54:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385022#M173814</guid>
      <dc:creator>andreacorvini</dc:creator>
      <dc:date>2019-01-04T08:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385023#M173815</link>
      <description>&lt;P&gt;I want to display only the host which have been loggend since less than 2 days and which have not rebooted since more 10 days&lt;BR /&gt;
you can see the result here&lt;BR /&gt;
&lt;A href="https://cjoint.com/c/IAejdxWgnFd"&gt;https://cjoint.com/c/IAejdxWgnFd&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 09:04:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385023#M173815</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-01-04T09:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385024#M173816</link>
      <description>&lt;P&gt;Ok, as you can see you don't have both values for the same event and in this case it's not possible with the logic in use. You have to use hostname and create a complete different search.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 09:37:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385024#M173816</guid>
      <dc:creator>andreacorvini</dc:creator>
      <dc:date>2019-01-04T09:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385025#M173817</link>
      <description>&lt;P&gt;No &lt;BR /&gt;
if you do this its on the same line&lt;/P&gt;

&lt;P&gt;index="ai-wkst-windows-wmi-fr" (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") &lt;BR /&gt;
| eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S") &lt;BR /&gt;
| eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S") &lt;BR /&gt;
| eval secondlastday=relative_time(now(), "-2d@d") &lt;BR /&gt;
| eval nexttendays=relative_time(now(), "+10d@d") &lt;BR /&gt;
 |stats latest(LastLogon) as LastLogon, latest(LastBootUpTime) as LastReboot by host&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:34:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385025#M173817</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2020-09-29T22:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385026#M173818</link>
      <description>&lt;P&gt;hi&lt;/P&gt;

&lt;P&gt;i use the request below but i have an issue with the where condition&lt;BR /&gt;
if i just use this part of code I have results corresponding&lt;BR /&gt;
| where (LastLogon &amp;lt; secondlastday) &lt;BR /&gt;
but when i use the entire request I m surprised to have no results&lt;BR /&gt;
| where (LastLogon &amp;lt; secondlastday)  AND (LastBootUpTime &amp;gt; nexttendays) &lt;BR /&gt;
so I wonder if there is no an issue in the relative time&lt;BR /&gt;
| eval nexttendays=relative_time(now(), "+10d@d")  means well that the query check all the machines wich have booted between today and ten days after??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ai-wkst-windows-wmi-fr" (sourcetype="WMI:LastLogon" OR sourcetype="WMI:LastReboot") 
| eval LastLogon = strptime(LastLogon,"%Y%m%d%H%M%S") 
| eval LastBootUpTime = strptime(LastBootUpTime,"%Y%m%d%H%M%S") 
| eval secondlastday=relative_time(now(), "-2d@d") 
| eval nexttendays=relative_time(now(), "+10d@d") 
| where (LastLogon &amp;lt; secondlastday) AND (LastBootUpTime &amp;gt; nexttendays) 
| stats latest(LastLogon) as LastLogon, latest(LastBootUpTime) as LastReboot by host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Jan 2019 13:16:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385026#M173818</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-01-04T13:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with relative time conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385027#M173819</link>
      <description>&lt;P&gt;Maybe, it's the result you want? Consider you are reading 2 different events in different time. If it's the result you need, it's ok.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 17:09:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-relative-time-conditions/m-p/385027#M173819</guid>
      <dc:creator>andreacorvini</dc:creator>
      <dc:date>2019-01-04T17:09:18Z</dc:date>
    </item>
  </channel>
</rss>

