<?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 subtract windows time stamps? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154027#M31306</link>
    <description>&lt;P&gt;round is not working here in the first place, but thanks for your effort &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Apr 2015 15:08:31 GMT</pubDate>
    <dc:creator>splunk_operator</dc:creator>
    <dc:date>2015-04-22T15:08:31Z</dc:date>
    <item>
      <title>How to subtract windows time stamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154025#M31304</link>
      <description>&lt;P&gt;In order to detect time changes of more than 20 seconds, I want to look into the Windows event "system time change" EventCode=4616 by computing the delta of the time change, subtract new time from previous time. I do not get a result from converting (mktime, ctime) neither from using strftime or strptime. It simply does not compute or even convert properly. Can anybody help? &lt;/P&gt;

&lt;P&gt;Previous Time:      ‎2015‎-‎04‎-‎22T12:40:15.083296800Z&lt;BR /&gt;
New Time:               ‎2015‎-‎04‎-‎22T12:40:15.073000000Z&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2015 12:49:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154025#M31304</guid>
      <dc:creator>splunk_operator</dc:creator>
      <dc:date>2015-04-22T12:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract windows time stamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154026#M31305</link>
      <description>&lt;P&gt;try like this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ...|eval duree=round(New Time) - round(Previous Time)|table "New Time" " Previous Time" duree | fieldformat duree=strftime(duree, "%H:%M:%S") |...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2015 14:51:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154026#M31305</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2015-04-22T14:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract windows time stamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154027#M31306</link>
      <description>&lt;P&gt;round is not working here in the first place, but thanks for your effort &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2015 15:08:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154027#M31306</guid>
      <dc:creator>splunk_operator</dc:creator>
      <dc:date>2015-04-22T15:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract windows time stamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154028#M31307</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| eval ptime="PREVIOUS TIME" | eval ntime="NEW TIME" | eval diff=ntime-ptime | where diff&amp;gt;20
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or, you could use a transaction which automatically calculates the duration:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=win EventCode=4616 | transaction EventCode | where duration&amp;gt;20
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2015 16:13:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154028#M31307</guid>
      <dc:creator>the_wolverine</dc:creator>
      <dc:date>2015-04-22T16:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract windows time stamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154029#M31308</link>
      <description>&lt;P&gt;Stumbling across this thread nearly 2 and a half years later, not sure if you got the response you needed.&lt;/P&gt;

&lt;P&gt;System time change, event code 4616, is a Windows event. Windows being Windows, there's always a strange set of characters in there somewhere. If you run a basic search and table _raw, you'll see part of the wineventlog entry labeled "Previous_time" or "New_Time".&lt;/P&gt;

&lt;P&gt;To extract this field normalize it, however, you have to copy the text from the _raw log into the search bar, and it'll show Window's odd little character between the things you can see.&lt;BR /&gt;
the # symbol in this eval statement is meant to represent the odd character in question&lt;/P&gt;

&lt;P&gt;| eval newTimestamp=strftime(round(strptime(New_Time, "#%Y#-#%m#-#%dT%H:%M:%S.%9QZ"),0), "%F - %T)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:26:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154029#M31308</guid>
      <dc:creator>Rhin0Crash</dc:creator>
      <dc:date>2020-09-29T16:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract windows time stamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154030#M31309</link>
      <description>&lt;P&gt;Hi, &lt;BR /&gt;
I am trying to subtract the _time as well, but i don't know why my simple eval is not working.&lt;BR /&gt;
here's my code:&lt;/P&gt;

&lt;P&gt;| convert ctime(_time) AS time&lt;BR /&gt;
| eval TID=if(Type=="Inbound",obj_type,corrID) &lt;BR /&gt;
| eval inboundTime=if(Type=="Inbound",time,null())&lt;BR /&gt;
| eval outboundTime=if(Type=="Outbound",time,null())&lt;BR /&gt;
| eval ResponseTime=strptime(outboundTime,"%Y%m%d %H:%M:%S.%N")-strptime(inboundTime,"%Y%m%d %H:%M:%S.%N")&lt;BR /&gt;
| stats values(inboundTime) AS starttime values(outboundTime) AS endtime values(ResponseTime) as ResponseTime  by TID&lt;/P&gt;

&lt;P&gt;I even tried a simpler approach:&lt;BR /&gt;
| eval ResponseTime=outboundTime-inboundTime&lt;/P&gt;

&lt;P&gt;But this is not working as well. &lt;BR /&gt;
help!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:45:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154030#M31309</guid>
      <dc:creator>chiennylin</dc:creator>
      <dc:date>2020-09-30T03:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract windows time stamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154031#M31310</link>
      <description>&lt;P&gt;try this&lt;BR /&gt;
 &lt;CODE&gt;| eval TID=if(Type=="Inbound",obj_type,corrID)&lt;BR /&gt;
| eval inboundTime=if(Type=="Inbound",time,null())&lt;BR /&gt;
| eval outboundTime=if(Type=="Outbound",time,null())&lt;BR /&gt;
| eval ResponseTime=outboundTime-inboundTime&lt;BR /&gt;
| convert ctime(_time) AS time&lt;BR /&gt;
| stats values(inboundTime) AS starttime values(outboundTime) AS endtime values(ResponseTime) as ResponseTime by TID&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2020 10:04:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154031#M31310</guid>
      <dc:creator>ashajambagi</dc:creator>
      <dc:date>2020-01-20T10:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract windows time stamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154032#M31311</link>
      <description>&lt;P&gt;Thanks for the answer, but it's not working.&lt;BR /&gt;
because the _time is used before hand.&lt;BR /&gt;
i even tried this:&lt;BR /&gt;
| eval TID=if(Type=="Inbound",obj_type,corrID) &lt;BR /&gt;
| eval inboundTime=if(Type=="Inbound",_time,null()) &lt;BR /&gt;
| eval outboundTime=if(Type=="Outbound",_time,null())&lt;BR /&gt;
| convert ctime(inboundTime) AS inboundTime&lt;BR /&gt;
| convert ctime(outboundTime) AS outboundTime&lt;BR /&gt;
| eval ResponseTime=outboundTime-inboundTime &lt;BR /&gt;
| stats values(inboundTime) AS starttime values(outboundTime) AS endtime values(ResponseTime) as ResponseTime by TID&lt;/P&gt;

&lt;P&gt;but its not working.&lt;BR /&gt;
it looks like this:&lt;/P&gt;

&lt;P&gt;TID starttime   endtime ResponseTime&lt;BR /&gt;
0b44ffc9-8e92-44a0-b487-da9acba0bc52    01/21/2020 00:12:45.168 01/21/2020 00:12:45.362&lt;BR /&gt;&lt;BR /&gt;
0d501b27-ad34-4481-bc16-7c029baa8bec    01/21/2020 00:10:56.951 01/21/2020 00:10:57.293  &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:46:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154032#M31311</guid>
      <dc:creator>chiennylin</dc:creator>
      <dc:date>2020-09-30T03:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract windows time stamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154033#M31312</link>
      <description>&lt;P&gt;try this &lt;BR /&gt;
&lt;CODE&gt;| eval TID=if(Type=="Inbound",obj_type,corrID)&lt;BR /&gt;
| eval inboundTime=if(Type=="Inbound",_time,null())&lt;BR /&gt;
| eval outboundTime=if(Type=="Outbound",_time,null())&lt;BR /&gt;
| eval ResponseTime=outboundTime-inboundTime&lt;BR /&gt;
| convert ctime(inboundTime) AS inboundTime&lt;BR /&gt;
| convert ctime(outboundTime) AS outboundTime &lt;BR /&gt;
|convert ctime(ResponseTime) as ResponseTime&lt;BR /&gt;
| stats values(inboundTime) AS starttime values(outboundTime) AS endtime values(ResponseTime) as ResponseTime by TID&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 04:55:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/154033#M31312</guid>
      <dc:creator>ashajambagi</dc:creator>
      <dc:date>2020-01-21T04:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract windows time stamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/529837#M89240</link>
      <description>&lt;P&gt;Ended up with the same challenge as listed here and none of the suggested replies on this article helped in any way.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my solution:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;my search&amp;gt; | rex field=New_Time mode=sed "s/[^ -~]//g"&amp;nbsp;&lt;BR /&gt;| rex field=Previous_Time mode=sed "s/[^ -~]//g"&lt;BR /&gt;| eval time_drift = (strptime(New_Time, "%Y-%m-%dT%H:%M:%S.%9QZ") - strptime(Previous_Time,"%Y-%m-%dT%H:%M:%S.%9QZ"))&lt;BR /&gt;| table _time New_Time time_drift&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Problem:&lt;BR /&gt;The field with the Windows timestamps includes non-printable character - I thinks it's a x80, but it doesn't really matter.&amp;nbsp; I use the rex mode=sed to remove anything that is not in the printable range.&lt;/P&gt;&lt;P&gt;[^ -~] matches all non-printable character, and mode=sed will just remove them from the string.&lt;/P&gt;&lt;P&gt;After this replacement, the strptime() function works correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 23:23:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-windows-time-stamps/m-p/529837#M89240</guid>
      <dc:creator>hnorvik</dc:creator>
      <dc:date>2020-11-17T23:23:59Z</dc:date>
    </item>
  </channel>
</rss>

