<?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 find the time difference in hours between the _time of two different fields ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245668#M73229</link>
    <description>&lt;P&gt;Thanks @cusello. What if i have something as below &lt;/P&gt;

&lt;P&gt;| convert ctime(a) timeformat="%H:%M"                                                                                                                 | convert ctime(stdev) timeformat="%H:%M"                                                                                                                 | convert ctime(y) timeformat="%H:%M"  &lt;/P&gt;

&lt;P&gt;How can i have the difference of y and a interms of %H:%M?&lt;/P&gt;</description>
    <pubDate>Wed, 23 Nov 2016 15:30:47 GMT</pubDate>
    <dc:creator>pavanae</dc:creator>
    <dc:date>2016-11-23T15:30:47Z</dc:date>
    <item>
      <title>How to find the time difference in hours between the _time of two different fields ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245663#M73224</link>
      <description>&lt;P&gt;I'm going crazy of calculating the difference between two fields which has epoch time. The following is my Query&lt;/P&gt;

&lt;P&gt;Updated :-&lt;/P&gt;

&lt;P&gt;foo  | convert ctime(_time) as Date_and_Time|convert timeformat="%m/%d/%Y %H:%M:%S" mktime(_time) as time |eventstats range(time) as duration by user| stats avg(duration) as avgDurationPeruser by user| eval Total_time_spent(out_of_school)=tostring(ceil(avgDurationPeruser), "duration")  | table user Total_AccessTime Total_time_spent(out_of_school)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:55:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245663#M73224</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2020-09-29T11:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the time difference in hours between the _time of two different fields ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245664#M73225</link>
      <description>&lt;P&gt;Try this:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/293049/calculating-the-time-difference-between-fields-how.html"&gt;https://answers.splunk.com/answers/293049/calculating-the-time-difference-between-fields-how.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 03:41:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245664#M73225</guid>
      <dc:creator>mrgibbon</dc:creator>
      <dc:date>2016-11-23T03:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the time difference in hours between the _time of two different fields ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245665#M73226</link>
      <description>&lt;P&gt;Hi  pavanae,&lt;BR /&gt;
sorry but I don't understand your question: the eval command correctly runs and gives the number of days between now() and the event's _time.&lt;BR /&gt;
In addition I don't understand the last "if" of your search, because it's incomplete.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 08:43:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245665#M73226</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-11-23T08:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the time difference in hours between the _time of two different fields ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245666#M73227</link>
      <description>&lt;P&gt;Sorry for posting the wrong Query. please find the updated Query. @cusello&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 13:25:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245666#M73227</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2016-11-23T13:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the time difference in hours between the _time of two different fields ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245667#M73228</link>
      <description>&lt;P&gt;Which are the fields to calculate difference?&lt;BR /&gt;
every way, you have to transform both the fields in epochtime&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval time1=strptime(time1,"%Y-%m-%d %H:%M:%S"), time2=strptime(time2,"%Y-%m-%d %H:%M:%S") | eval diff=time1-time2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;speculating that time format is %Y-%m-%d %H:%M:%S&lt;BR /&gt;
_time is already in epochtime.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 13:39:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245667#M73228</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-11-23T13:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the time difference in hours between the _time of two different fields ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245668#M73229</link>
      <description>&lt;P&gt;Thanks @cusello. What if i have something as below &lt;/P&gt;

&lt;P&gt;| convert ctime(a) timeformat="%H:%M"                                                                                                                 | convert ctime(stdev) timeformat="%H:%M"                                                                                                                 | convert ctime(y) timeformat="%H:%M"  &lt;/P&gt;

&lt;P&gt;How can i have the difference of y and a interms of %H:%M?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 15:30:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245668#M73229</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2016-11-23T15:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the time difference in hours between the _time of two different fields ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245669#M73230</link>
      <description>&lt;P&gt;You can use&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval y=tostring(y,"duration") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 15:34:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-difference-in-hours-between-the-time-of-two/m-p/245669#M73230</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-11-23T15:34:39Z</dc:date>
    </item>
  </channel>
</rss>

