<?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 calculate time difference between 2 fields | sum and group by month in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/calculate-time-difference-between-2-fields-sum-and-group-by/m-p/59425#M14628</link>
    <description>&lt;P&gt;I have a log that looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;start_time="2011-11-19T13:32:59" end_time="2011-11-19T13:34:59"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I create a report that shows the total duration by month?&lt;/P&gt;

&lt;P&gt;I would like to do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search | eval xduration=(end_time-start_time) | stats sum(xduration) by date_month
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the above, of course, does not work. How do I get Splunk to recognize the vaules in the start_time and end_time fields as timestamps?&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 10:22:13 GMT</pubDate>
    <dc:creator>andyk</dc:creator>
    <dc:date>2020-09-28T10:22:13Z</dc:date>
    <item>
      <title>calculate time difference between 2 fields | sum and group by month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/calculate-time-difference-between-2-fields-sum-and-group-by/m-p/59425#M14628</link>
      <description>&lt;P&gt;I have a log that looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;start_time="2011-11-19T13:32:59" end_time="2011-11-19T13:34:59"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I create a report that shows the total duration by month?&lt;/P&gt;

&lt;P&gt;I would like to do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search | eval xduration=(end_time-start_time) | stats sum(xduration) by date_month
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the above, of course, does not work. How do I get Splunk to recognize the vaules in the start_time and end_time fields as timestamps?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:22:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/calculate-time-difference-between-2-fields-sum-and-group-by/m-p/59425#M14628</guid>
      <dc:creator>andyk</dc:creator>
      <dc:date>2020-09-28T10:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference between 2 fields | sum and group by month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/calculate-time-difference-between-2-fields-sum-and-group-by/m-p/59426#M14629</link>
      <description>&lt;P&gt;You should first convert to epoch time, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| convert timeformat="%y-%m-%dT%H:%M:%S" mktime(end_time) mktime(start_time) | eval duration=end_time-start_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Jan 2012 13:31:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/calculate-time-difference-between-2-fields-sum-and-group-by/m-p/59426#M14629</guid>
      <dc:creator>imrago</dc:creator>
      <dc:date>2012-01-27T13:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference between 2 fields | sum and group by month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/calculate-time-difference-between-2-fields-sum-and-group-by/m-p/59427#M14630</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;When I do what is says above the duration I get return is off by 2 hours...?&lt;BR /&gt;
I'm using the following:&lt;BR /&gt;
Search |&lt;BR /&gt;
convert timeformat="%d-%m-%Y %H:%M:%S" mktime(ADCreatedTime) |&lt;BR /&gt;
convert timeformat="%d-%m-%Y %H:%M:%S" mktime(FIMCreatedTime) |&lt;BR /&gt;
where ADCreatedTime &amp;gt; FIMCreatedTime |&lt;BR /&gt;
Eval Duration = ADCreatedTime - FIMCreatedTime |&lt;/P&gt;

&lt;P&gt;convert timeformat="%H:%M:%S" ctime(Duration) as D |&lt;BR /&gt;
convert timeformat="%d-%m-%Y %H:%M:%S" ctime(ADCreatedTime) as ADC |&lt;BR /&gt;
convert timeformat="%d-%m-%Y %H:%M:%S" ctime(FIMCreatedTime) as FDC |&lt;BR /&gt;
Table user, FDC, ADC, D &lt;/P&gt;

&lt;P&gt;The results are:&lt;BR /&gt;
user            FDC                     ADC                     D&lt;BR /&gt;
abiggelaar  25-03-2011 11:02:34 25-03-2011 12:05:49 03:03:15&lt;BR /&gt;
ahayward    16-02-2011 12:54:59 16-02-2011 13:57:49 03:02:50&lt;BR /&gt;
beheer.danaher  04-03-2011 09:49:39 04-03-2011 10:53:39 03:04:00&lt;/P&gt;

&lt;P&gt;I can't find any time zone stuff going wrong.&lt;BR /&gt;
Can anyone point me in the right direction? Thanks!&lt;BR /&gt;
Wim&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2012 08:43:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/calculate-time-difference-between-2-fields-sum-and-group-by/m-p/59427#M14630</guid>
      <dc:creator>wimvdheijkant</dc:creator>
      <dc:date>2012-11-21T08:43:29Z</dc:date>
    </item>
  </channel>
</rss>

