<?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: Calculate the difference between two datetimes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-between-two-datetimes/m-p/730522#M227475</link>
    <description>&lt;P&gt;One value - the other gives you a number of seconds (and any fraction). So simple arithmetic knowing the number of seconds in a day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data junk;
   x='24MAR2021:13:24:49.287000'dt;
   y='24MAR2021:13:30:46.886000'dt;
   diff = (y-x)/(24*60*60);
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 31 Mar 2021 21:16:18 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-03-31T21:16:18Z</dc:date>
    <item>
      <title>Calculate the difference between two datetimes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-between-two-datetimes/m-p/730519#M227473</link>
      <description>&lt;P&gt;I’m attempting to calculate the difference between two datetimes by day, hour, minute and second. &amp;nbsp;The datetimes are in DATETIME26.6 (ddMMMyyyy:00:00:00.000000) format.&lt;/P&gt;
&lt;P&gt;I’d like to result to be day.hour,min,sec&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&lt;U&gt;StartDate&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;U&gt;EndDate&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;U&gt;Wanted Result – D.hms&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;3/24/2021 13:24:49.287000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3/24/2021 13:30:46.886000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.004&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2/4/2021 15:25:58.501000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3/8/2021 13:59:51.848000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;31.941&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I’ve tried Intck, however seems to be limited to only one increment and looking at the whole number instead of breaking it down by the time increments I need.&amp;nbsp;&amp;nbsp; Any suggestions are welcome! thanks&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 21:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-between-two-datetimes/m-p/730519#M227473</guid>
      <dc:creator>ScotchCat</dc:creator>
      <dc:date>2021-03-31T21:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between two datetimes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-between-two-datetimes/m-p/730522#M227475</link>
      <description>&lt;P&gt;One value - the other gives you a number of seconds (and any fraction). So simple arithmetic knowing the number of seconds in a day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data junk;
   x='24MAR2021:13:24:49.287000'dt;
   y='24MAR2021:13:30:46.886000'dt;
   diff = (y-x)/(24*60*60);
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Mar 2021 21:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-between-two-datetimes/m-p/730522#M227475</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-31T21:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between two datetimes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-between-two-datetimes/m-p/730524#M227476</link>
      <description>Does 31.941 mean 31 days, 9 hours, 4 minutes and 1 second? How would you display 31 days, 9 hours and 41 minutes even?&lt;BR /&gt;&lt;BR /&gt;day.hour,min,sec is a very unique format so I'm assuming I'm wrong here....&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 31 Mar 2021 21:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-between-two-datetimes/m-p/730524#M227476</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-31T21:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between two datetimes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-between-two-datetimes/m-p/730625#M227536</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input start_date : mmddyy10. start_time :time15. end_date :mmddyy10. end_time :time15.;
start_dt = dhms(start_date,0,0,start_time);
end_dt = dhms(end_date,0,0,end_time);
diff = (end_dt - start_dt) / 86400;
format
  start_date end_date yymmdd10.
  start_time end_time time15.6
  start_dt end_dt e8601dt26.6
  diff 10.3
;
datalines;
3/24/2021 13:24:49.287000          3/24/2021 13:30:46.886000
2/4/2021 15:25:58.501000            3/8/2021 13:59:51.848000
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please do us a favor and post your data as data step with datalines, so we can recreate it by copy/pasting and submitting the code.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 09:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-between-two-datetimes/m-p/730625#M227536</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-01T09:58:48Z</dc:date>
    </item>
  </channel>
</rss>

