<?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: Subtracting two epoch times after within stats table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556522#M158052</link>
    <description>&lt;P&gt;It ended up being my fault.&amp;nbsp; I was able to use an element of your example to produce the results I was looking for:&lt;BR /&gt;&lt;BR /&gt;|eval duration = last_event - first_event&lt;BR /&gt;|eval possible_duration=tostring(duration, "duration")&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jun 2021 13:38:13 GMT</pubDate>
    <dc:creator>jason_hotchkiss</dc:creator>
    <dc:date>2021-06-21T13:38:13Z</dc:date>
    <item>
      <title>Subtracting two epoch times after within stats table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556048#M157888</link>
      <description>&lt;P&gt;Hello - we are trying to calculate the possible_duration between the first event and last event in the following base search:&lt;BR /&gt;&lt;BR /&gt;&amp;lt;base_search&amp;gt;&lt;BR /&gt;| eval docid="&lt;A title="https://www.youtube.com/embed/%22.docid" href="https://www.youtube.com/embed/%22.docid" target="_blank" rel="noreferrer noopener"&gt;https://www.youtube.com/embed/".docid&lt;/A&gt;&lt;BR /&gt;| stats count as "visits" values(docid) as url list(_time) as time_of_events earliest(_time) as first_event latest(_time) as last_event by user&lt;BR /&gt;| eval duration = last_event - first_event&lt;BR /&gt;| eval possible_duration = strftime(duration,"%H:%M:%S")&lt;BR /&gt;| eval time_of_events = strftime(time_of_events,"%H:%M:%S")&lt;BR /&gt;| eval first_event = strftime(first_event,"%H:%M:%S")&lt;BR /&gt;| eval last_event = strftime(last_event,"%H:%M:%S")&lt;BR /&gt;| table user visits url time_of_events first_event last_event possible_duration&lt;BR /&gt;&lt;BR /&gt;Result:&lt;/P&gt;&lt;DIV&gt;&lt;TABLE width="602"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="107"&gt;Scoobie_Doo&lt;/TD&gt;&lt;TD width="105"&gt;3&lt;/TD&gt;&lt;TD width="100"&gt;&lt;A href="https://www.youtube.com/embed/scoobie_snacks" target="_blank" rel="noopener"&gt;https://www.youtube.com/embed/scoobie_snacks&lt;/A&gt;&lt;/TD&gt;&lt;TD width="98"&gt;16:12:37&lt;BR /&gt;16:12:37&lt;BR /&gt;16:12:34&lt;/TD&gt;&lt;TD width="64"&gt;16:12:34&lt;/TD&gt;&lt;TD width="64"&gt;16:12:37&lt;/TD&gt;&lt;TD width="64"&gt;19:00:03&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;The possible_duration field seems to get the minutes and seconds right.&amp;nbsp; But not the hour.&amp;nbsp; Looking for a suggestion one what I am missing.&lt;/DIV&gt;</description>
      <pubDate>Wed, 16 Jun 2021 20:28:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556048#M157888</guid>
      <dc:creator>jason_hotchkiss</dc:creator>
      <dc:date>2021-06-16T20:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two epoch times after within stats table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556062#M157894</link>
      <description>&lt;P&gt;Using strftime on a duration type field will always take account your local time, so if you added in a date to that strftime, you would see it's probably Jan 1 1970.&lt;/P&gt;&lt;P&gt;When dealing with duration there are two ways, either using tostring or doing the maths, like this example search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval duration=147
| eval t-UsingToString=tostring(duration,"duration")
| eval h=round(duration/3600), m=round((duration-(h*3600))/60), s=duration%60
| eval t-UsingHMS=printf("%02d:%02d:%02d", h, m, s)
| table duration t-UsingToString t-UsingHMS&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 23:13:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556062#M157894</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-16T23:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two epoch times after within stats table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556187#M157932</link>
      <description>&lt;P&gt;I attempted your solution, however, I am unable to get it to work in my particular case.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 14:41:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556187#M157932</guid>
      <dc:creator>jason_hotchkiss</dc:creator>
      <dc:date>2021-06-17T14:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two epoch times after within stats table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556243#M157950</link>
      <description>&lt;P&gt;Can you give more details on what you tried and the results you got.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 22:45:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556243#M157950</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-17T22:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two epoch times after within stats table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556522#M158052</link>
      <description>&lt;P&gt;It ended up being my fault.&amp;nbsp; I was able to use an element of your example to produce the results I was looking for:&lt;BR /&gt;&lt;BR /&gt;|eval duration = last_event - first_event&lt;BR /&gt;|eval possible_duration=tostring(duration, "duration")&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 13:38:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtracting-two-epoch-times-after-within-stats-table/m-p/556522#M158052</guid>
      <dc:creator>jason_hotchkiss</dc:creator>
      <dc:date>2021-06-21T13:38:13Z</dc:date>
    </item>
  </channel>
</rss>

