<?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 do I convert epoch time to HH:MM:SS? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224494#M66135</link>
    <description>&lt;P&gt;Hi Gyslainlatsa, thanks for your help. However once I have added strftime to the code, I cannot average my results.&lt;/P&gt;

&lt;P&gt;I also cannot use | stats avg(Diff) before making my conversion.&lt;/P&gt;

&lt;P&gt;Is there a solution to this?&lt;/P&gt;</description>
    <pubDate>Wed, 11 Nov 2015 13:27:11 GMT</pubDate>
    <dc:creator>mjd555</dc:creator>
    <dc:date>2015-11-11T13:27:11Z</dc:date>
    <item>
      <title>How do I convert epoch time to HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224491#M66132</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Background&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;So I have two date fields - &lt;STRONG&gt;Date_Created&lt;/STRONG&gt; &amp;amp; &lt;STRONG&gt;Acknowledge_Date&lt;/STRONG&gt; both in the format &lt;CODE&gt;YYYY-MM-DD HH:MM:SS&lt;/CODE&gt;. I wish to work out the difference of these two times and then create an average of all the results - essentially this -&amp;gt; &lt;CODE&gt;Average(Acknowledge_Date-Date_Created)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Search&lt;/STRONG&gt;&lt;BR /&gt;
I have created the following search. This has converted the times to epoch, subtracted them, and provided an average of the epoch time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="Cyber" sourcetype=Response queue = "Incident" status ="resolved"  | dedup ticket

    | table Date_Created, Acknowledge_Date 
    | eval epoch1=strptime(Date_Created,"%Y-%m-%d %H:%M:%S") 
    | convert timeformat="%Y-%m-%d %H:%M:%S" mktime(Date_Created) as epochDateCreated
    | eval epoch2=strptime(Acknowledge_Date,"%Y-%m-%d %H:%M:%S")
    | convert timeformat="%Y-%m-%d %H:%M:%S" mktime(Acknowledge_Date) as epochAck
    | eval Diff=(epochAck-epochDateCreated)

    |stats avg(Diff)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Problem&lt;/STRONG&gt;&lt;BR /&gt;
I now have an average number in epoch format - 5848.333333 - is there a way to convert this into HH:MM:SS&lt;/P&gt;

&lt;P&gt;Any help will be much appreciated &lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 11:26:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224491#M66132</guid>
      <dc:creator>mjd555</dc:creator>
      <dc:date>2015-11-11T11:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert epoch time to HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224492#M66133</link>
      <description>&lt;P&gt;hi mjd555,&lt;/P&gt;

&lt;P&gt;try following this link &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;BR /&gt;
and look the function &lt;CODE&gt;strftime(X,Y)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 12:53:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224492#M66133</guid>
      <dc:creator>gyslainlatsa</dc:creator>
      <dc:date>2015-11-11T12:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert epoch time to HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224493#M66134</link>
      <description>&lt;P&gt;Hi gyslainlatsa, so I strftime has helped me see the time difference in HH:MM:SS - however I cannot avg these results. Is there a way to do this? Thanks again!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="Cyber" sourcetype=Response queue = "Incident" status ="resolved"  | dedup ticket

         | table Date_Created, Acknowledge_Date 
         | eval epoch1=strptime(Date_Created,"%Y-%m-%d %H:%M:%S") 
         | convert timeformat="%Y-%m-%d %H:%M:%S" mktime(Date_Created) as epochDateCreated
         | eval epoch2=strptime(Acknowledge_Date,"%Y-%m-%d %H:%M:%S")
         | convert timeformat="%Y-%m-%d %H:%M:%S" mktime(Acknowledge_Date) as epochAck
         | eval epochDiff=(epochAck-epochDateCreated)
         | eval normalDiff=strftime(epochDiff, "%H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Nov 2015 13:20:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224493#M66134</guid>
      <dc:creator>mjd555</dc:creator>
      <dc:date>2015-11-11T13:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert epoch time to HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224494#M66135</link>
      <description>&lt;P&gt;Hi Gyslainlatsa, thanks for your help. However once I have added strftime to the code, I cannot average my results.&lt;/P&gt;

&lt;P&gt;I also cannot use | stats avg(Diff) before making my conversion.&lt;/P&gt;

&lt;P&gt;Is there a solution to this?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 13:27:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224494#M66135</guid>
      <dc:creator>mjd555</dc:creator>
      <dc:date>2015-11-11T13:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert epoch time to HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224495#M66136</link>
      <description>&lt;P&gt;Your command would be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval DiffTime=strftime(Diff, "%H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Nov 2015 13:27:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224495#M66136</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2015-11-11T13:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert epoch time to HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224496#M66137</link>
      <description>&lt;P&gt;Hi DMohn. | eval DiffTime=strftime(Diff, "%H:%M:%S") helps me convert the epoch time to the format I want. However I cannot appear to get | stats avg(DiffTime) when it is in this format.&lt;/P&gt;

&lt;P&gt;I also cannot use |stats avg(Diff) before making the conversion.&lt;/P&gt;

&lt;P&gt;Is there a solution to this?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 13:31:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224496#M66137</guid>
      <dc:creator>mjd555</dc:creator>
      <dc:date>2015-11-11T13:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert epoch time to HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224497#M66138</link>
      <description>&lt;P&gt;If you wanted to look at the average time in hours that an incident ticket was open you could use this search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="Cyber" sourcetype=Response queue="Incident" status="resolved" 
| dedup ticket  
| eval Diff=floor(((strptime(Acknowledge_Date,"%Y-%m-%d %H:%M:%S"))-(strptime(Date_Created,"%Y-%m-%d %H:%M:%S")))/(3600)) 
| stats avg(Diff)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this works for you. &lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 18:49:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224497#M66138</guid>
      <dc:creator>tmccamant</dc:creator>
      <dc:date>2015-11-11T18:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert epoch time to HH:MM:SS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224498#M66139</link>
      <description>&lt;P&gt;Hi tmccamant,&lt;/P&gt;

&lt;P&gt;Afraid this hasn't worked as it has left me with the result of -15.208333&lt;/P&gt;

&lt;P&gt;Any other ideas will be greatly appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 09:42:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-epoch-time-to-HH-MM-SS/m-p/224498#M66139</guid>
      <dc:creator>mjd555</dc:creator>
      <dc:date>2015-11-12T09:42:23Z</dc:date>
    </item>
  </channel>
</rss>

