<?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: Time Comparison - Windows in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Time-Comparison-Windows/m-p/305120#M57525</link>
    <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I am glad you found it working. Do post the question about data issue for the community to assist, unless that is resolved.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2018 16:34:22 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-01-23T16:34:22Z</dc:date>
    <item>
      <title>Time Comparison - Windows</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Time-Comparison-Windows/m-p/305117#M57522</link>
      <description>&lt;P&gt;I am trying to compare two windows time stamps, and find out if they are more than 10 minutes apart. The time stamps are in the following format:&lt;BR /&gt;
‎2018‎-‎01‎-‎12T21:13:31.535000000Z&lt;BR /&gt;
YYYY-MM-DDTHH:MM:SS&lt;/P&gt;

&lt;P&gt;It seems like it would make sense to use the function relative_time:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.5/SearchReference/CommonEvalFunctions" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.5/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;BR /&gt;
| eval n=relative_time(now(), "-1d@d") aka | eval n=relative_time(, )&lt;BR /&gt;
The resulting value should be the number of seconds the two values are different, if I understand the description correctly.&lt;/P&gt;

&lt;P&gt;Then compare the value of "n" to see if it is over 600 (10-minutes x 60-seconds). &lt;/P&gt;

&lt;P&gt;I am guessing that the windows formatting of the time values is throwing Splunk off. Though, as this format is coming straight from a windows log, I had thought that they would be able to be read. &lt;/P&gt;

&lt;P&gt;Is this a case where the time/date will have to be parsed out, and then compared?&lt;/P&gt;

&lt;P&gt;Has anyone worked with this type of time format before?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:38:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Time-Comparison-Windows/m-p/305117#M57522</guid>
      <dc:creator>stakor</dc:creator>
      <dc:date>2020-09-29T17:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Time Comparison - Windows</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Time-Comparison-Windows/m-p/305118#M57523</link>
      <description>&lt;P&gt;@stakor, you can convert the two time fields to epoch time using &lt;CODE&gt;strptime()&lt;/CODE&gt; evaluation function (if one or both are in String time format). Once you convert them to String time, you can subtract them to get the difference in time in seconds, will will allow you to check whether they are 600 seconds apart or not.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt;
| eval start_time=strptime(start_time,"%Y-%m-%dT%H:%M:%S.%9NZ"),end_time=strptime(end_time,"%Y-%m-%dT%H:%M:%S.%9NZ")
| eval duration=(end_time-start_time)
| search duration&amp;gt;600
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere example illustrating the same:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval start_time="2018-01-12T21:13:31.535000000Z", end_time="2018-01-12T22:20:40.231000000Z"
| fields - _time
| eval start_time=strptime(start_time,"%Y-%m-%dT%H:%M:%S.%9NZ"),end_time=strptime(end_time,"%Y-%m-%dT%H:%M:%S.%9NZ")
| eval duration=(end_time-start_time)
| search duration&amp;gt;600
| fieldformat start_time=strftime(start_time,"%Y-%m-%dT%H:%M:%S.%9NZ")
| fieldformat end_time=strftime(end_time,"%Y-%m-%dT%H:%M:%S.%9NZ")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: &lt;CODE&gt;strptime()&lt;/CODE&gt; converts String Time to Epoch Time and &lt;CODE&gt;strftime()&lt;/CODE&gt; converts Epoch time to String time. The &lt;CODE&gt;fieldformat&lt;/CODE&gt; command is used to display String Time while retaining the underlying Epoch Time. If &lt;CODE&gt;eval&lt;/CODE&gt; is used in place of &lt;CODE&gt;fieldformat&lt;/CODE&gt; it will modify the underlying data as well. You can refer to Splunk Documentation for all these commands/functions.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 01:14:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Time-Comparison-Windows/m-p/305118#M57523</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-01-13T01:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Time Comparison - Windows</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Time-Comparison-Windows/m-p/305119#M57524</link>
      <description>&lt;P&gt;Thank you for your answer. It is very informative, and when I post it my clean up date into your stand alone formula, it works. (Great way to provide a formula to show the work, I didn't think that was possible.) &lt;/P&gt;

&lt;P&gt;I seem to also be having some sort of odd dirty data problem on one system. I am going to try the other one, and see if it is across both of them. But one system has an odd character around the numbers when I copy paste it, or export it into CSV output. I am trying to figure out what the character is, and why it is there.&lt;/P&gt;

&lt;P&gt;But, when I remove it, it works like a charm. I want to try to test it a little on the other system, and then I will mark this answer as accepted for this question. Then I will probably post something relating to the dirty data, if I can not clean it up myself.&lt;/P&gt;

&lt;P&gt;Again,&lt;BR /&gt;
Really good answer.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 20:07:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Time-Comparison-Windows/m-p/305119#M57524</guid>
      <dc:creator>stakor</dc:creator>
      <dc:date>2018-01-16T20:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Time Comparison - Windows</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Time-Comparison-Windows/m-p/305120#M57525</link>
      <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I am glad you found it working. Do post the question about data issue for the community to assist, unless that is resolved.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 16:34:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Time-Comparison-Windows/m-p/305120#M57525</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-01-23T16:34:22Z</dc:date>
    </item>
  </channel>
</rss>

