<?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: Calculate time difference with extracted fields and offset time zones in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-with-extracted-fields-and-offset-time/m-p/549995#M156078</link>
    <description>&lt;P&gt;The only way to calculate a difference between time fields is to convert them into integers using &lt;FONT face="courier new,courier"&gt;strptime&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype="PCF:log" cf_app_name=app1 (msg="*message query here*")
| rex field=msg "created on\s+(?&amp;lt;lockTime&amp;gt;\S+\s+\S+)"
| eval elockTime = strptime(lockTime, "%Y-%m-%d %H:%M:%S.%3N")
| eval Expected = elockTime - _time - (5*3600)
| table _time,lockTime, Expected&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 30 Apr 2021 12:27:02 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2021-04-30T12:27:02Z</dc:date>
    <item>
      <title>Calculate time difference with extracted fields and offset time zones</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-with-extracted-fields-and-offset-time/m-p/549899#M156057</link>
      <description>&lt;P&gt;I've got logs that contain a timestamp in 24 hour YYYY-MM-DD HH:MM:ss:SSS format (example:&amp;nbsp;&lt;SPAN&gt;2021-04-29 18:43:07.557).&amp;nbsp; The timestamp in this log message is +5 hours ahead of the _time of the event.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I've got this much, which extracts the timestamp from the message but I don't know how to go about showing the difference between these two, especially with the five hour offset.&amp;nbsp; Ideally would just like to show a third value of the difference in the table.&amp;nbsp; Appreciate any instruction.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sourcetype="PCF:log" cf_app_name=app1 (msg="*message query here*")&lt;BR /&gt;| rex field=msg "created on\s+(?&amp;lt;lockTime&amp;gt;\S+\s+\S+)"&lt;BR /&gt;| table _time,lockTime&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;_time&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;lockTime&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Expected&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;2021-04-28 12:46:37.381&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;2021-04-28 17:46:33.961&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;00:00:03.420&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I should mention too that only the time portion, not the date, will need the difference calculated.&amp;nbsp; The YYYY-MM-DD will always be the same between _time and lockTime.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 19:49:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-with-extracted-fields-and-offset-time/m-p/549899#M156057</guid>
      <dc:creator>mrhodes93</dc:creator>
      <dc:date>2021-04-29T19:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference with extracted fields and offset time zones</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-with-extracted-fields-and-offset-time/m-p/549995#M156078</link>
      <description>&lt;P&gt;The only way to calculate a difference between time fields is to convert them into integers using &lt;FONT face="courier new,courier"&gt;strptime&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype="PCF:log" cf_app_name=app1 (msg="*message query here*")
| rex field=msg "created on\s+(?&amp;lt;lockTime&amp;gt;\S+\s+\S+)"
| eval elockTime = strptime(lockTime, "%Y-%m-%d %H:%M:%S.%3N")
| eval Expected = elockTime - _time - (5*3600)
| table _time,lockTime, Expected&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 30 Apr 2021 12:27:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-with-extracted-fields-and-offset-time/m-p/549995#M156078</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-04-30T12:27:02Z</dc:date>
    </item>
  </channel>
</rss>

