<?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 How to convert time as DD:HH:MM:SS in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-time-as-DD-HH-MM-SS/m-p/429290#M122819</link>
    <description>&lt;P&gt;How can I convert 2+12:54:32 as 2:12:54:32 (2 days 12 hours 54 minutes 32 seconds)&lt;/P&gt;

&lt;P&gt;Current search is this : &lt;/P&gt;

&lt;P&gt;| eval duration_time= tostring(duration_time, "duration") &lt;BR /&gt;
| eval formatted_dur = replace(duration_time,"(?:(\d+)+)?0?(\d+):0?(\d+):0?(\d+)","\1d \2h \3m \4s") &lt;/P&gt;

&lt;P&gt;Which produces attached screenshots.. When we are sorting from highest time --&amp;gt; to lowest time .. it puts days  as the lowest in the sort.&lt;IMG src="https://community.splunk.com/storage/temp/251153-splunk-sort-search-2.png" alt="alt text" /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 20:21:31 GMT</pubDate>
    <dc:creator>Sp3ctre1</dc:creator>
    <dc:date>2020-09-29T20:21:31Z</dc:date>
    <item>
      <title>How to convert time as DD:HH:MM:SS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-time-as-DD-HH-MM-SS/m-p/429290#M122819</link>
      <description>&lt;P&gt;How can I convert 2+12:54:32 as 2:12:54:32 (2 days 12 hours 54 minutes 32 seconds)&lt;/P&gt;

&lt;P&gt;Current search is this : &lt;/P&gt;

&lt;P&gt;| eval duration_time= tostring(duration_time, "duration") &lt;BR /&gt;
| eval formatted_dur = replace(duration_time,"(?:(\d+)+)?0?(\d+):0?(\d+):0?(\d+)","\1d \2h \3m \4s") &lt;/P&gt;

&lt;P&gt;Which produces attached screenshots.. When we are sorting from highest time --&amp;gt; to lowest time .. it puts days  as the lowest in the sort.&lt;IMG src="https://community.splunk.com/storage/temp/251153-splunk-sort-search-2.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:21:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-time-as-DD-HH-MM-SS/m-p/429290#M122819</guid>
      <dc:creator>Sp3ctre1</dc:creator>
      <dc:date>2020-09-29T20:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert time as DD:HH:MM:SS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-time-as-DD-HH-MM-SS/m-p/429291#M122820</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your root search ... 
| rex field=duration_time "(?&amp;lt;days&amp;gt;\d+)?\+?(?&amp;lt;hours&amp;gt;\d+):(?&amp;lt;minutes&amp;gt;\d+):(?&amp;lt;seconds&amp;gt;\d+)\.(?&amp;lt;micro&amp;gt;\d+)" 
| eval elapsed=86400*days+3600*hours+60*minutes+seconds 
| table elapsed duration_time 
| sort elapsed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If that looks good, add this to the end to remove the elapsed field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fields - elapsed
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Jul 2018 13:10:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-time-as-DD-HH-MM-SS/m-p/429291#M122820</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-07-09T13:10:18Z</dc:date>
    </item>
  </channel>
</rss>

