<?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 to take the time from the field I am interested in and compare that to the current time to mark as an alert? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453740#M128400</link>
    <description>&lt;P&gt;Adjusted my query and this has worked as expected.  &lt;/P&gt;

&lt;P&gt;I can see that my time format was wrong with respect to the %I and %p (I will look at the SPLUNK documentation around those formats).&lt;/P&gt;

&lt;P&gt;Can you please explain why the eval is done with the diff and what is the purpose of the divide by 145440/0?&lt;BR /&gt;
Is "where diff" by default days?  Can this be modified to months or even years?  &lt;/P&gt;</description>
    <pubDate>Mon, 23 Jul 2018 05:57:11 GMT</pubDate>
    <dc:creator>willadams</dc:creator>
    <dc:date>2018-07-23T05:57:11Z</dc:date>
    <item>
      <title>How to take the time from the field I am interested in and compare that to the current time to mark as an alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453738#M128398</link>
      <description>&lt;P&gt;I am exporting data out of AD and trying to look for devices that are older than a certain time frame.  From my data extract I have the following date information (amongst a bunch of others) for the field I am interested in&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;lastLogonDate&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;The field lastLogonDate has the following format in the CSV&lt;/P&gt;

&lt;P&gt;20-Jul-18 8:36:38PM&lt;/P&gt;

&lt;P&gt;I have written the following evaluation to try and convert this text field to a time I can use in SPLUNK to try and figure out whether the machine was last seen in say the last 60 days.&lt;/P&gt;

&lt;P&gt;| eval logondate_epoch=strptime(lastLogonDate, "%d-%b-%y %H:%M:%S"&lt;/P&gt;

&lt;P&gt;I am then trying &lt;/P&gt;

&lt;P&gt;| where logondate_epoch &amp;gt; 60 days&lt;/P&gt;

&lt;P&gt;But this results in the error "operator at 'days' is invalid.&lt;/P&gt;

&lt;P&gt;How do I take the time from the field I am interested in and compare that to the current time less 60 (or however many) days to mark as an alert? &lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 02:59:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453738#M128398</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2018-07-23T02:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to take the time from the field I am interested in and compare that to the current time to mark as an alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453739#M128399</link>
      <description>&lt;P&gt;@willadams ,&lt;/P&gt;

&lt;P&gt;First of all the strptime format is not matching with your date format. Please try below and validate with your environment.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your searches"
|eval logondate_epoch=strptime(lastLogonDate, "%d-%b-%y %I:%M:%S%p")
|eval diff=round((now()-logondate_epoch)/86400,0)
|where diff &amp;gt; 60
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jul 2018 05:23:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453739#M128399</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-07-23T05:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to take the time from the field I am interested in and compare that to the current time to mark as an alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453740#M128400</link>
      <description>&lt;P&gt;Adjusted my query and this has worked as expected.  &lt;/P&gt;

&lt;P&gt;I can see that my time format was wrong with respect to the %I and %p (I will look at the SPLUNK documentation around those formats).&lt;/P&gt;

&lt;P&gt;Can you please explain why the eval is done with the diff and what is the purpose of the divide by 145440/0?&lt;BR /&gt;
Is "where diff" by default days?  Can this be modified to months or even years?  &lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 05:57:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453740#M128400</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2018-07-23T05:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to take the time from the field I am interested in and compare that to the current time to mark as an alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453741#M128401</link>
      <description>&lt;P&gt;Okay I can see where the match for strptime was wrong.  The %I being for 12 hour clock vs the %H being 24 hours; and %p for AM/PM.  &lt;/P&gt;

&lt;P&gt;Still need to understand the diff though&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 06:25:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453741#M128401</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2018-07-23T06:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to take the time from the field I am interested in and compare that to the current time to mark as an alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453742#M128402</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/79922"&gt;@willadams&lt;/a&gt;,&lt;BR /&gt;
That was typo with 145440,its corrected in answer.&lt;/P&gt;

&lt;P&gt;The unix time stamp is merely the number of seconds between a particular date and the Unix Epoch and hence the diff returns is the difference in &lt;CODE&gt;number of seconds&lt;/CODE&gt;. Since we want to have number of days, we divide the seconds&lt;BR /&gt;
seconds/60=minutes&lt;BR /&gt;
minutes/60=hours&lt;BR /&gt;
hours/24=days&lt;BR /&gt;
which is resulting in 60*60*24 = 86400&lt;/P&gt;

&lt;P&gt;And yes, you can convert it to any time duration. Just need to convert these seconds to the time unit by dividing it appropriately.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:34:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453742#M128402</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2020-09-29T20:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to take the time from the field I am interested in and compare that to the current time to mark as an alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453743#M128403</link>
      <description>&lt;P&gt;Appreciated.  Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 07:51:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-take-the-time-from-the-field-I-am-interested-in-and/m-p/453743#M128403</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2018-07-23T07:51:42Z</dc:date>
    </item>
  </channel>
</rss>

