<?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: Time value difference in duration: getting value as 0d in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Time-value-difference-in-duration-getting-value-as-0d/m-p/445191#M126294</link>
    <description>&lt;P&gt;THanks a lot for the answer. &lt;/P&gt;</description>
    <pubDate>Fri, 07 Sep 2018 08:24:57 GMT</pubDate>
    <dc:creator>Chandras11</dc:creator>
    <dc:date>2018-09-07T08:24:57Z</dc:date>
    <item>
      <title>Time value difference in duration: getting value as 0d</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-value-difference-in-duration-getting-value-as-0d/m-p/445189#M126292</link>
      <description>&lt;P&gt;HI All,&lt;/P&gt;

&lt;P&gt;I am able to get the time value difference in epoch and able to convert it to string with the following command:-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval LeadDays = ( Answer_Time - Bookingdate) |  eval LeadDays = tostring(LeadDays, "duration") |

Bookingdate             Answer_Time  LeadDays
1535635518.000000   1535708751.000000   20:20:33.000000
1535636031.000000   1536059535.000000   2+21:38:24.000000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is in the first row: is there a way to convert it to 0+20:20:33.000000 instead of 20:20:33.000000  &lt;/P&gt;

&lt;P&gt;I tried to use string concat but it didnt work. &lt;/P&gt;

&lt;P&gt;Also is there a way to convert 2+21:38:24 to only days as 2+21/24+38/3600= 2.88 days  &lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 15:30:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-value-difference-in-duration-getting-value-as-0d/m-p/445189#M126292</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-09-06T15:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Time value difference in duration: getting value as 0d</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-value-difference-in-duration-getting-value-as-0d/m-p/445190#M126293</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval LeadDays = if(like(LeadDays,"%+%"), LeadDays, "0+".LeadDays)
| rex field=LeadDays "^(?&amp;lt;days&amp;gt;[^\+]+)\+(?&amp;lt;hours&amp;gt;[^:]+)\:(?&amp;lt;minutes&amp;gt;[^:]+)"
| eval new_LeadDays = round(days + hours/24 + minutes/3600, 2)
| fields - days hours minutes
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Explanation:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;first preppend a "0+" if the LeadDays doesn't contain a "+" in it&lt;/LI&gt;
&lt;LI&gt;capture the days / hours / minutes into different fields&lt;/LI&gt;
&lt;LI&gt;use the fields captured in #2 to calculate a new field as per your requirements&lt;/LI&gt;
&lt;LI&gt;remove the unnecessary fields&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 16:01:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-value-difference-in-duration-getting-value-as-0d/m-p/445190#M126293</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2018-09-06T16:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Time value difference in duration: getting value as 0d</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-value-difference-in-duration-getting-value-as-0d/m-p/445191#M126294</link>
      <description>&lt;P&gt;THanks a lot for the answer. &lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 08:24:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-value-difference-in-duration-getting-value-as-0d/m-p/445191#M126294</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-09-07T08:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Time value difference in duration: getting value as 0d</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-value-difference-in-duration-getting-value-as-0d/m-p/445192#M126295</link>
      <description>&lt;P&gt;I was trying to use the match command in eval case and it was giving me issues. This one is working like a charm. &lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 09:05:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-value-difference-in-duration-getting-value-as-0d/m-p/445192#M126295</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-09-07T09:05:47Z</dc:date>
    </item>
  </channel>
</rss>

