<?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 calculate working hours between start and end DateTime in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-working-hours-between-start-and-end-DateTime/m-p/24215#M177501</link>
    <description>&lt;P&gt;What do you mean by "calculating" hours?&lt;/P&gt;</description>
    <pubDate>Thu, 02 Aug 2012 17:01:04 GMT</pubDate>
    <dc:creator>Ayn</dc:creator>
    <dc:date>2012-08-02T17:01:04Z</dc:date>
    <item>
      <title>How to calculate working hours between start and end DateTime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-working-hours-between-start-and-end-DateTime/m-p/24214#M177500</link>
      <description>&lt;P&gt;I am trying to build a working hours report with splunk...&lt;/P&gt;

&lt;P&gt;I have a start date and an end date like so:&lt;/P&gt;

&lt;P&gt;start_time&lt;BR /&gt;
2012-07-03 12:56:07&lt;/P&gt;

&lt;P&gt;end_time&lt;BR /&gt;
2012-07-14 16:30:22&lt;/P&gt;

&lt;P&gt;calculating calendar hours is simple but how do i get working hours?&lt;/P&gt;

&lt;P&gt;any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2012 15:00:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-working-hours-between-start-and-end-DateTime/m-p/24214#M177500</guid>
      <dc:creator>kenchisho</dc:creator>
      <dc:date>2012-08-02T15:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate working hours between start and end DateTime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-working-hours-between-start-and-end-DateTime/m-p/24215#M177501</link>
      <description>&lt;P&gt;What do you mean by "calculating" hours?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2012 17:01:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-working-hours-between-start-and-end-DateTime/m-p/24215#M177501</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-08-02T17:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate working hours between start and end DateTime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-working-hours-between-start-and-end-DateTime/m-p/24216#M177502</link>
      <description>&lt;P&gt;well the number of working hours between the start_time and end_time&lt;/P&gt;

&lt;P&gt;for example i start working on a task at 09:00 AM on monday and finish at 13:00 PM on wednesday... i wish to count the number of working hours on the task...&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:11:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-working-hours-between-start-and-end-DateTime/m-p/24216#M177502</guid>
      <dc:creator>kenchisho</dc:creator>
      <dc:date>2020-09-28T12:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate working hours between start and end DateTime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-working-hours-between-start-and-end-DateTime/m-p/24217#M177503</link>
      <description>&lt;P&gt;you can convert your time to epochtime, ft not already done or use the splunk timestamp (in  _time as epoch time)&lt;BR /&gt;
if you want other time calculations, use eval.&lt;/P&gt;

&lt;P&gt;see &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.3/SearchReference/Convert" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/4.3.3/SearchReference/Convert&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;
mysearch_for_my_task 
| convert timeformat="%Y-%M-%d %H:%M:%S" start_second=mktime(start_time) AS start_second
| convert timeformat="%Y-%M-%d %H:%M:%S" start_second=mktime(end_time) AS end_second
| eval duration_second=end_second-start_second
| eval duration_hour=round(duration_second/360,0)
| table duration_hour
&lt;/PRE&gt;

&lt;P&gt;if the timestamp is the timestamp of the event, you can try a transaction&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
mysearch | transaction mycommonfield startswith="keyword1" endswith="keyword2" &lt;BR /&gt;
| table mycommonfield _time duration&lt;BR /&gt;
&lt;/PRE&gt;&lt;BR /&gt;
or use stats&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
mysearch | stats first(_time) AS recent last(_time) AS oldest by mycommonfield &lt;BR /&gt;
| eval duration_second=recent-oldest &lt;BR /&gt;
| eval duration_second=end_second-start_second&lt;BR /&gt;
| eval duration_hour=round(duration_second/360,0)&lt;BR /&gt;
| table mycommonfield duration_hour&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:11:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-working-hours-between-start-and-end-DateTime/m-p/24217#M177503</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2020-09-28T12:11:58Z</dc:date>
    </item>
  </channel>
</rss>

