<?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: Find Number of Days, Hours, and Minutes between Two Dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-Number-of-Days-Hours-and-Minutes-between-Two-Dates/m-p/579905#M164669</link>
    <description>Thanks, Tom!  I knew it had to be something simpler than I was making it.</description>
    <pubDate>Thu, 08 Aug 2019 15:17:19 GMT</pubDate>
    <dc:creator>djbateman</dc:creator>
    <dc:date>2019-08-08T15:17:19Z</dc:date>
    <item>
      <title>Find Number of Days, Hours, and Minutes between Two Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Number-of-Days-Hours-and-Minutes-between-Two-Dates/m-p/579900#M164666</link>
      <description>&lt;P&gt;I am trying to create a report that shows a list of subjects, their date/time of first dose, date/time of last dose, and the difference between the two date/times.&amp;nbsp; I am supposed to report the difference in the format "D Days:HH:MM".&amp;nbsp; In other words, if the first dose date/time was 01JAN2019:08:00 and the last dose date/time was 05JAN2019:09:30, then the result for the difference would say, "4 Days:01:30".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been able to use INTNX to get the number of days, but how would I further extract the hours and minutes that has transpired?&amp;nbsp; I think my biggest concern is if the example above had the times swapped: 01JAN2019:09:30 and 05JAN2019:08:00.&amp;nbsp; In this case, the difference should be "3 Days:22:30".&amp;nbsp; I don't think INTNX would produce the proper number of days.&amp;nbsp; It would still return 4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a sample dataset to help get you started.&amp;nbsp; Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table have (SUBJECT char(11), MINDTTM num format=datetime18., MAXDTTM num format=datetime18.);
	insert into have (subject, mindttm, maxdttm)
		values('001-001-001','06DEC2018:07:35:00'dt,'08JAN2019:08:24:00'dt)
		values('001-001-002','06DEC2018:07:50:00'dt,'07JAN2019:07:17:00'dt)
		values('001-001-003','07DEC2018:08:30:00'dt,'07JAN2019:07:30:00'dt)
		values('001-001-004','07DEC2018:08:40:00'dt,'18MAR2019:07:49:00'dt)
		values('001-001-005','01JAN2019:08:00:00'dt,'05JAN2019:09:30:00'dt)
		values('001-001-006','01JAN2019:09:30:00'dt,'05JAN2019:08:00:00'dt);
quit;

data want;
	set have;
	daydiff=intck('DTDAY',mindttm,maxdttm);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 14:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Number-of-Days-Hours-and-Minutes-between-Two-Dates/m-p/579900#M164666</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2019-08-08T14:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find Number of Days, Hours, and Minutes between Two Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Number-of-Days-Hours-and-Minutes-between-Two-Dates/m-p/579901#M164667</link>
      <description>&lt;P&gt;Just take the difference, which will be a value in seconds.&amp;nbsp; To display it as DAY and HH:MM then split the value using 24Hours.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;seconds=maxdttm - mindtdtm;
days=int(seconds/'24:00't);
hhmm=mod(seconds,'24:00't);
string=catx('/',catx(' ',days,'days'),put(hhmm,tod5.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Aug 2019 15:06:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Number-of-Days-Hours-and-Minutes-between-Two-Dates/m-p/579901#M164667</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-08T15:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Find Number of Days, Hours, and Minutes between Two Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Number-of-Days-Hours-and-Minutes-between-Two-Dates/m-p/579905#M164669</link>
      <description>Thanks, Tom!  I knew it had to be something simpler than I was making it.</description>
      <pubDate>Thu, 08 Aug 2019 15:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Number-of-Days-Hours-and-Minutes-between-Two-Dates/m-p/579905#M164669</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2019-08-08T15:17:19Z</dc:date>
    </item>
  </channel>
</rss>

