<?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 without errors in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Time-without-errors/m-p/262620#M175819</link>
    <description>&lt;P&gt;Try something like this. The _time field is already epoch so you don't need to convert it again.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
| head 1
| eval TimeWithoutErrors = tostring(now()-_time,"duration")
| eval TimeNow= strftime(now(),"%Y-%m-%d %H:%M:%S.%3N")
| eval EventTime = strftime(_time,"%Y-%m-%d %H:%M:%S.%3N")
| table TimeWithoutErrors, TimeNow, _time, EventTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 27 Jan 2017 15:06:20 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-01-27T15:06:20Z</dc:date>
    <item>
      <title>Time without errors</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-without-errors/m-p/262619#M175818</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I'm trying to calculate the time without errors in the system. To do that I'm doing something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval now = now()
| convert timeformat="%Y-%m-%d %H:%M:%S.%3N" mktime(_time) AS epoch_time
| eval diff = now - epoch_time
| eval TimeWithoutErrors = strftime(diff,"%H:%M:%S")
| eval TimeNow = strftime(now,"%Y-%m-%d %H:%M:%S.%3N")
| eval EventTime = strftime(epoch_time,"%Y-%m-%d %H:%M:%S.%3N")
| head 1
| table TimeWithoutErrors, TimeNow, _time, EventTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the values I get are:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;TimeNow: 2017-01-27 14:18:16.000 -&amp;gt; correct&lt;/LI&gt;
&lt;LI&gt;_time: 2017-01-27 12:00:14.552 -&amp;gt; correct&lt;/LI&gt;
&lt;LI&gt;EventTime: 2017-01-27 12:00:14.552 -&amp;gt; correct&lt;/LI&gt;
&lt;LI&gt;TimeWithoutErrors: 03:18:01 -&amp;gt; not correct, should be one hour less&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Why I'm getting an hour more that what I should get?&lt;/P&gt;

&lt;P&gt;Thank you very much,&lt;BR /&gt;
Vicenç&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 14:23:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-without-errors/m-p/262619#M175818</guid>
      <dc:creator>vgaltes</dc:creator>
      <dc:date>2017-01-27T14:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Time without errors</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-without-errors/m-p/262620#M175819</link>
      <description>&lt;P&gt;Try something like this. The _time field is already epoch so you don't need to convert it again.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
| head 1
| eval TimeWithoutErrors = tostring(now()-_time,"duration")
| eval TimeNow= strftime(now(),"%Y-%m-%d %H:%M:%S.%3N")
| eval EventTime = strftime(_time,"%Y-%m-%d %H:%M:%S.%3N")
| table TimeWithoutErrors, TimeNow, _time, EventTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Jan 2017 15:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-without-errors/m-p/262620#M175819</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-27T15:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Time without errors</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-without-errors/m-p/262621#M175820</link>
      <description>&lt;P&gt;Works perfectly, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 16:08:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-without-errors/m-p/262621#M175820</guid>
      <dc:creator>vgaltes</dc:creator>
      <dc:date>2017-01-27T16:08:09Z</dc:date>
    </item>
  </channel>
</rss>

