<?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: Eval Epoch Duration Time into Human Readable Format in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-Epoch-Duration-Time-into-Human-Readable-Format/m-p/471277#M132579</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="indexhere" AND (EventCode="4624" OR EventCode="4634") AND AccountName="*"
| stats min(_time) AS Logon max(_time) AS Logoff range(_time) AS duration BY AccountName
| fieldformat Logon = strftime(Logon, "%x %r")
| fieldformat Logoff = strftime(Logoff, "%x %r")
| fieldformat duration = tostring(duration, "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 20 Dec 2019 10:59:23 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-12-20T10:59:23Z</dc:date>
    <item>
      <title>Eval Epoch Duration Time into Human Readable Format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Epoch-Duration-Time-into-Human-Readable-Format/m-p/471275#M132577</link>
      <description>&lt;P&gt;I am using the following query to show the duration of a accounts logon and logoff. The results come back in epoch time, and if I make changes to time using eval strftime, it negates the duration. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Index=indexhere EventCode=4624 OR EventCode=4634 AccountName="*" | stats earliest(eval(if(EventCode=4624, _time, null()))) as Logon latesteval(eval(if(EventCode=4634, _time, null()))) as Logoff by AccountName | eval duration=Logoff-Logon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I add &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Index=indexhere EventCode=4624 OR EventCode=4634 AccountName="*" | eval time=strftime(_time,"%x %r") | stats earliest(eval(if(EventCode=4624, time, null()))) as Logon latesteval(eval(if(EventCode=4634, time, null()))) as Logoff by AccountName | eval duration=Logoff-Logon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;it converts the &lt;CODE&gt;Logon&lt;/CODE&gt; and &lt;CODE&gt;Logoff&lt;/CODE&gt;, but the &lt;CODE&gt;duration&lt;/CODE&gt; field comes up blank. I am assuming its due to &lt;CODE&gt;duration&lt;/CODE&gt; not being able to compute the modified time format.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2019 23:50:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Epoch-Duration-Time-into-Human-Readable-Format/m-p/471275#M132577</guid>
      <dc:creator>migullmills</dc:creator>
      <dc:date>2019-12-19T23:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Epoch Duration Time into Human Readable Format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Epoch-Duration-Time-into-Human-Readable-Format/m-p/471276#M132578</link>
      <description>&lt;P&gt;@migullmills &lt;/P&gt;

&lt;P&gt;Yes, &lt;CODE&gt;_time&lt;/CODE&gt; gives numeric values (epoch time ) in &lt;CODE&gt;Logon&lt;/CODE&gt; and &lt;CODE&gt;Logoff&lt;/CODE&gt; so you can do mathematical operation. like  &lt;CODE&gt;| eval duration=Logoff-Logon&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eval time=strftime(_time,"%x %r")&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;strftime&lt;/CODE&gt;  gives you human readable string so mathematical operation will return null here.&lt;/P&gt;

&lt;P&gt;So here I suggest you to use first search,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Index=indexhere EventCode=4624 OR EventCode=4634 AccountName="*" 
| stats earliest(eval(if(EventCode=4624, _time, null()))) as Logon latesteval(eval(if(EventCode=4634, _time, null()))) as Logoff by AccountName 
| eval duration=Logoff-Logon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want &lt;CODE&gt;duration&lt;/CODE&gt; field in human readable format then try by adding below search block.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;|eval myduration=tostring(duration,"duration")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 04:42:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Epoch-Duration-Time-into-Human-Readable-Format/m-p/471276#M132578</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-12-20T04:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Epoch Duration Time into Human Readable Format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Epoch-Duration-Time-into-Human-Readable-Format/m-p/471277#M132579</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="indexhere" AND (EventCode="4624" OR EventCode="4634") AND AccountName="*"
| stats min(_time) AS Logon max(_time) AS Logoff range(_time) AS duration BY AccountName
| fieldformat Logon = strftime(Logon, "%x %r")
| fieldformat Logoff = strftime(Logoff, "%x %r")
| fieldformat duration = tostring(duration, "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Dec 2019 10:59:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Epoch-Duration-Time-into-Human-Readable-Format/m-p/471277#M132579</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-20T10:59:23Z</dc:date>
    </item>
  </channel>
</rss>

