<?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 to find the difference between two date values and subtracting weekend days? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444818#M77429</link>
    <description>&lt;P&gt;hi @Chandras11&lt;/P&gt;

&lt;P&gt;can u try like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval ASSIGNED_DT = "2018-08-22 15:33:51" | eval ANSWER_DT= "2018-09-03 16:59:48" | eval Assigned_Time = strptime(ASSIGNED_DT, "%Y-%m-%d %H:%M:%S")   | eval Answer_Time = strptime(ANSWER_DT, "%Y-%m-%d %H:%M:%S")  |  eval start=relative_time(Assigned_Time,"@d") | eval end=relative_time(Answer_Time,"@d") | eval Date=mvrange(start,end+86400,86400) | convert ctime(Date) timeformat="%+" | eval WeekendDays=mvcount(mvfilter(match(Date,"(Sun|Sat).*"))) | eval diff = ( Answer_Time - Assigned_Time) |eval diff=(diff-(WeekendDays*86400)) | eval diff = tostring(diff, "duration") | table ASSIGNED_DT, ANSWER_DT, diff,  WeekendDays
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 06 Sep 2018 09:47:04 GMT</pubDate>
    <dc:creator>harishalipaka</dc:creator>
    <dc:date>2018-09-06T09:47:04Z</dc:date>
    <item>
      <title>How to find the difference between two date values and subtracting weekend days?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444817#M77428</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I need to find the difference between these two dates with the removal of the weekends&lt;/P&gt;

&lt;P&gt;I have 2 date value fields as &lt;BR /&gt;
ASSIGNED_DT = 2018-08-30 15:33:51 &lt;BR /&gt;
ANSWER_DT= 2018-09-03 16:59:48&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   | makeresults | eval ASSIGNED_DT = "2018-08-22 15:33:51" | eval ANSWER_DT= "2018-09-03 16:59:48" | eval Assigned_Time = strptime(ASSIGNED_DT, "%Y-%m-%d %H:%M:%S")   | eval Answer_Time = strptime(ANSWER_DT, "%Y-%m-%d %H:%M:%S")  |  eval start=relative_time(Assigned_Time,"@d") | eval end=relative_time(Answer_Time,"@d") | eval Date=mvrange(start,end+86400,86400) | convert ctime(Date) timeformat="%+" | eval WeekendDays=mvcount(mvfilter(match(Date,"(Sun|Sat).*"))) | eval diff = tostring(( Answer_Time - Assigned_Time), "duration") | table ASSIGNED_DT, ANSWER_DT, diff,  WeekendDays 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Everything is working fine and the results are:-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ASSIGNED_DT              ANSWER_DT         diff                 WeekendDays
2018-08-22 15:33:51 2018-09-03 16:59:48 12+01:25:57.000000  4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I just need help with: &lt;BR /&gt;
1. remove the WeekendDays from the diff&lt;BR /&gt;
2. Convert diff-WeekendDays as the only number of days in decimal: for example here : it should be 8.01 days or 8 days 1 hour 25 mins only. &lt;/P&gt;

&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:09:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444817#M77428</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2020-09-29T21:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the difference between two date values and subtracting weekend days?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444818#M77429</link>
      <description>&lt;P&gt;hi @Chandras11&lt;/P&gt;

&lt;P&gt;can u try like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval ASSIGNED_DT = "2018-08-22 15:33:51" | eval ANSWER_DT= "2018-09-03 16:59:48" | eval Assigned_Time = strptime(ASSIGNED_DT, "%Y-%m-%d %H:%M:%S")   | eval Answer_Time = strptime(ANSWER_DT, "%Y-%m-%d %H:%M:%S")  |  eval start=relative_time(Assigned_Time,"@d") | eval end=relative_time(Answer_Time,"@d") | eval Date=mvrange(start,end+86400,86400) | convert ctime(Date) timeformat="%+" | eval WeekendDays=mvcount(mvfilter(match(Date,"(Sun|Sat).*"))) | eval diff = ( Answer_Time - Assigned_Time) |eval diff=(diff-(WeekendDays*86400)) | eval diff = tostring(diff, "duration") | table ASSIGNED_DT, ANSWER_DT, diff,  WeekendDays
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Sep 2018 09:47:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444818#M77429</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2018-09-06T09:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the difference between two date values and subtracting weekend days?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444819#M77430</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Thanks for the response. Yes, it's working perfectly.&lt;BR /&gt;
Can we convert the diff 8+01:25:57.000000 into days with decimal values: for example 8.01 days here&lt;/P&gt;

&lt;P&gt;BR,&lt;BR /&gt;
Chandra &lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 09:52:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444819#M77430</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-09-06T09:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the difference between two date values and subtracting weekend days?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444820#M77431</link>
      <description>&lt;P&gt;hi @Chandras11 &lt;/P&gt;

&lt;P&gt;try like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval ASSIGNED_DT = "2018-08-22 15:33:51" | eval ANSWER_DT= "2018-09-03 16:59:48" | eval Assigned_Time = strptime(ASSIGNED_DT, "%Y-%m-%d %H:%M:%S")   | eval Answer_Time = strptime(ANSWER_DT, "%Y-%m-%d %H:%M:%S")  |  eval start=relative_time(Assigned_Time,"@d") | eval end=relative_time(Answer_Time,"@d") | eval Date=mvrange(start,end+86400,86400) | convert ctime(Date) timeformat="%+" | eval WeekendDays=mvcount(mvfilter(match(Date,"(Sun|Sat).*"))) | eval diff = ( Answer_Time - Assigned_Time) |eval diff=(diff-(WeekendDays*86400)) | eval diff = tostring(diff, "duration") | table ASSIGNED_DT, ANSWER_DT, diff,  WeekendDays |eval temp=split(diff,"+") |eval temp2=split(mvindex(temp,1),":") |eval diff=mvindex(temp,0)+"."+mvindex(temp2,0)+" "+"days" | table ASSIGNED_DT, ANSWER_DT, diff,  WeekendDays
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Sep 2018 10:16:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444820#M77431</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2018-09-06T10:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the difference between two date values and subtracting weekend days?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444821#M77432</link>
      <description>&lt;P&gt;perfect.. thanks a lot for it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;BR /&gt;
its working fine... &lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 10:38:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444821#M77432</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-09-06T10:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the difference between two date values and subtracting weekend days?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444822#M77433</link>
      <description>&lt;P&gt;Hi @harishalipaka , &lt;/P&gt;

&lt;P&gt;Could you also please provide the query to find the difference in hours instead of day's by excluding weekend days. &lt;/P&gt;

&lt;P&gt;because in my similar scenario there would be a chance where assigned and answer date is same day. &lt;/P&gt;

&lt;P&gt;Thanks in Advance..!!!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 17:04:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-find-the-difference-between-two-date-values-and/m-p/444822#M77433</guid>
      <dc:creator>Dheerj</dc:creator>
      <dc:date>2019-11-22T17:04:03Z</dc:date>
    </item>
  </channel>
</rss>

