<?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: Calculating date differences with the minutes interval but excluding work days in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778359#M31513</link>
    <description>&lt;P&gt;First thing, clarify your actual need. The subject of the post says "excluding work days", the body of your question says&lt;FONT size="4"&gt; "but we can't find how to exclude workdays at the minutes level." and then you example shows: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;FONT size="2"&gt;12MAR21:16:55:08&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15MAR21:16:22:22&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.98 &lt;EM&gt;(needs to exclude weekend)&lt;/EM&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Two of these things are not like the other.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;You also really don't mention what UNITS your result is supposed to be.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Details: Assuming a Friday to Monday interval, what &lt;STRONG&gt;time&lt;/STRONG&gt; on FRIDAY to stop incrementing time? What &lt;STRONG&gt;time&lt;/STRONG&gt; on MONDAY to you start incrementing the time?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;And for an obnoxious kicker, what about Holidays? What do you expect to happen when a Holiday is in the interval?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The basic approach would be to test your two values to get the days of the week involved.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Dayofweek = weekday(datepart(beg_date)); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Friday is 6, Monday is 2 for example. Then decide using that information if a weekend (week day???) is involved.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Then you get to apply the not-stated yet rule for how much time is accumulated for which days on the outside of your exclusion period needs to be counted. There is going to be some If/Then/else logic involved.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;You would split things up such as &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;FirstBit = ((intck('minute',beg_date,&amp;lt;date time to stop for end of day friday&amp;gt;))60)/24;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Secondbit= ((intck('minute',&amp;lt;date time to start for monday&amp;gt;,end_date))60)/24;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Then add Firstbit and secondbit.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The INTNX function and/or DHMS would be in the second bit.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;But without an example of the exact times involved I'm not going to write code.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Nov 2021 22:18:22 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-11-03T22:18:22Z</dc:date>
    <item>
      <title>Calculating date differences with the minutes interval but excluding work days</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778329#M31510</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Hi, I need to calculate a turnaround time (tat) between two dates, to 2 decimal points, excluding work days. A team member helped me figure out the 1st part of the calculation, but we can't find how to exclude workdays at the minutes level. We'd appreciate some direction on this. Thank you.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;What we have so far:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; TATcheck;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;infile datalines dsd truncover;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;format beg_date datetime16. end_date datetime16.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;input beg_date:datetime16. end_date:datetime16.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;22MAR21:03:06:00,22MAR2021:18:16:00&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;17MAR21:13:23:00,17MAR2021:16:23:00&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;07APR21:12:29:00,07APR2021:17:34:00&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;12MAR21:16:55:08,15MAR2021:16:22:22&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;13MAR21:04:31:16, 15MAR2021:17:46:02&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;data tatcheck2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;set tatcheck;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;format tat &lt;STRONG&gt;6.2&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;tat = ((intck('minute',beg_date,end_date))/&lt;STRONG&gt;60&lt;/STRONG&gt;)/&lt;STRONG&gt;24&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Results:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Beg_date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; End_date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tat&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;22MAR21:03:06:00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22MAR21:18:16:00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.63 &lt;EM&gt;(correct)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;17MAR21:13:23:00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 17MAR21:16:23:00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.13 &lt;EM&gt;(correct)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;07APR21:12:29:00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 07APR21:17:34:00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.21 &lt;EM&gt;(correct)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;12MAR21:16:55:08&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15MAR21:16:22:22&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.98 &lt;EM&gt;(needs to exclude weekend)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;13MAR21:04:31:16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15MAR21:17:46:02&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.55 &lt;EM&gt;(needs to exclude weekend)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 20:17:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778329#M31510</guid>
      <dc:creator>MBE57</dc:creator>
      <dc:date>2021-11-03T20:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating date differences with the minutes interval but excluding work days</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778358#M31512</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Is the below program giving you what you want?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TATcheck;
infile datalines dsd truncover;
format beg_date datetime16. end_date datetime16.;
 input beg_date:datetime16. end_date:datetime16.;
datalines;
22MAR21:03:06:00,22MAR2021:18:16:00
17MAR21:13:23:00,17MAR2021:16:23:00
07APR21:12:29:00,07APR2021:17:34:00
12MAR21:16:55:08,15MAR2021:16:22:22
13MAR21:04:31:16,15MAR2021:17:46:02
;
run;

data tatcheck3(drop=i);
 set tatcheck;
 format tat: 6.2;
 tat_exclude_weekend = 0;
 tat_exclude_workday = 0;
 do i = INTNX('dtminute',beg_date,0) to INTNX('dtminute',end_date,0) by 60;
  if weekday(datepart(i)) NOT IN (1,7)       then tat_exclude_weekend=tat_exclude_weekend+1;
  if weekday(datepart(i)) NOT IN (2,3,4,5,6) then tat_exclude_workday=tat_exclude_workday+1;
 end;
 tat_exclude_weekend = (tat_exclude_weekend/60)/24;
 tat_exclude_workday = (tat_exclude_workday/60)/24;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 22:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778358#M31512</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-03T22:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating date differences with the minutes interval but excluding work days</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778359#M31513</link>
      <description>&lt;P&gt;First thing, clarify your actual need. The subject of the post says "excluding work days", the body of your question says&lt;FONT size="4"&gt; "but we can't find how to exclude workdays at the minutes level." and then you example shows: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;FONT size="2"&gt;12MAR21:16:55:08&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15MAR21:16:22:22&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.98 &lt;EM&gt;(needs to exclude weekend)&lt;/EM&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Two of these things are not like the other.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;You also really don't mention what UNITS your result is supposed to be.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Details: Assuming a Friday to Monday interval, what &lt;STRONG&gt;time&lt;/STRONG&gt; on FRIDAY to stop incrementing time? What &lt;STRONG&gt;time&lt;/STRONG&gt; on MONDAY to you start incrementing the time?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;And for an obnoxious kicker, what about Holidays? What do you expect to happen when a Holiday is in the interval?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The basic approach would be to test your two values to get the days of the week involved.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Dayofweek = weekday(datepart(beg_date)); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Friday is 6, Monday is 2 for example. Then decide using that information if a weekend (week day???) is involved.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Then you get to apply the not-stated yet rule for how much time is accumulated for which days on the outside of your exclusion period needs to be counted. There is going to be some If/Then/else logic involved.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;You would split things up such as &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;FirstBit = ((intck('minute',beg_date,&amp;lt;date time to stop for end of day friday&amp;gt;))60)/24;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Secondbit= ((intck('minute',&amp;lt;date time to start for monday&amp;gt;,end_date))60)/24;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Then add Firstbit and secondbit.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The INTNX function and/or DHMS would be in the second bit.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;But without an example of the exact times involved I'm not going to write code.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 22:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778359#M31513</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-03T22:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating date differences with the minutes interval but excluding work days</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778472#M31529</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TATcheck;
infile datalines dsd truncover;
format beg_date datetime16. end_date datetime16.;
 input beg_date:datetime16. end_date:datetime16.;
datalines;
22MAR21:03:06:00,22MAR2021:18:16:00
17MAR21:13:23:00,17MAR2021:16:23:00
07APR21:12:29:00,07APR2021:17:34:00
12MAR21:16:55:08,15MAR2021:16:22:22
13MAR21:04:31:16,15MAR2021:17:46:02
;
run;
data want;
 set tatcheck;
 seconds=0;
 do i=beg_date to end_date;
   if weekday(datepart(i)) not in (1 7) then seconds+1;
 end;
 tat=seconds/60/60/24;
 drop seconds i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Nov 2021 11:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778472#M31529</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-11-04T11:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating date differences with the minutes interval but excluding work days</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778485#M31531</link>
      <description>Thank you for your help, it's appreciated very much.</description>
      <pubDate>Thu, 04 Nov 2021 13:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-date-differences-with-the-minutes-interval-but/m-p/778485#M31531</guid>
      <dc:creator>MBE57</dc:creator>
      <dc:date>2021-11-04T13:12:17Z</dc:date>
    </item>
  </channel>
</rss>

