<?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 calculate difference between two dates when one dat with time and another has only date v in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781704#M249124</link>
    <description>&lt;P&gt;In addition to the above requests, we need additional information. Are these variables numeric or character? How are they formatted? Please show us the PROC CONTENTS output for these two variables.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Nov 2021 12:33:48 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-11-22T12:33:48Z</dc:date>
    <item>
      <title>how to calculate difference between two dates when one dat with time and another has only date vari</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781664#M249103</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to calculate difference&amp;nbsp; for these two dates&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;DTC_1&lt;/TD&gt;&lt;TD&gt;DTC_2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-06-11T22:20&lt;/TD&gt;&lt;TD&gt;2021-06-12&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-08-30T16:58&lt;/TD&gt;&lt;TD&gt;2021-10-05&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-10-05T07:17&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-10-07T15:14&lt;/TD&gt;&lt;TD&gt;2021-10-08&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-10-09T16:22&lt;/TD&gt;&lt;TD&gt;2021-10-10&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-08-30T09:54&lt;/TD&gt;&lt;TD&gt;2021-08-30&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Required difference should look like this&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Required date diff&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;46:22:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;40:58:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;39:14:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;40:22:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;09:54&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 13:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781664#M249103</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2021-11-22T13:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate difference between two dates when one dat with time and another has only date v</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781665#M249104</link>
      <description>&lt;P&gt;How do you want the difference to be measured?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 07:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781665#M249104</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-11-22T07:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate difference between two dates when one dat with time and another has only date v</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781667#M249106</link>
      <description>with time as difference</description>
      <pubDate>Mon, 22 Nov 2021 07:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781667#M249106</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2021-11-22T07:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate difference between two dates when one dat with time and another has only date v</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781675#M249110</link>
      <description>&lt;P&gt;Please post data in usable form and show what you expect as result for each observation. Since the second variable is a date, not a datetime, your task needs clarification.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 07:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781675#M249110</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-11-22T07:22:06Z</dc:date>
    </item>
    <item>
      <title>how to find diff between dtc_2 - dtc_1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781699#M249134</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to calculate difference&amp;nbsp; for these two dates&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;DTC_1&lt;/TD&gt;&lt;TD&gt;DTC_2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-06-11T22:20&lt;/TD&gt;&lt;TD&gt;2021-06-12&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-08-30T16:58&lt;/TD&gt;&lt;TD&gt;2021-10-05&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-10-05T07:17&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-10-07T15:14&lt;/TD&gt;&lt;TD&gt;2021-10-08&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-10-09T16:22&lt;/TD&gt;&lt;TD&gt;2021-10-10&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-08-30T09:54&lt;/TD&gt;&lt;TD&gt;2021-08-30&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Required difference should look like this&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Required date diff&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;26:22:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;40:58:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;39:14:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;40:22:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;09:54&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 12:17:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781699#M249134</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2021-11-22T12:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to find diff between dtc_2 - dtc_1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781701#M249135</link>
      <description>&lt;P&gt;Duplicate thread. all responses should go to the other thread at&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781664#M249103" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781664#M249103&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 12:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781701#M249135</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-22T12:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate difference between two dates when one dat with time and another has only date v</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781704#M249124</link>
      <description>&lt;P&gt;In addition to the above requests, we need additional information. Are these variables numeric or character? How are they formatted? Please show us the PROC CONTENTS output for these two variables.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 12:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781704#M249124</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-22T12:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate difference between two dates when one dat with time and another has only date v</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781705#M249125</link>
      <description>they are populated in charatcer format</description>
      <pubDate>Mon, 22 Nov 2021 12:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781705#M249125</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2021-11-22T12:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate difference between two dates when one dat with time and another has only date v</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781710#M249130</link>
      <description>&lt;P&gt;Please explain how for record 1, the desired output is 26:22:00.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to me the difference is 1 hour and 40 minutes.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 13:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781710#M249130</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-22T13:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to find diff between dtc_2 - dtc_1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781714#M249136</link>
      <description>&lt;P&gt;I have merged the both threads.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 13:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781714#M249136</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-11-22T13:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate difference between two dates when one dat with time and another has only date v</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781718#M249139</link>
      <description>the difference for one record is one day and 22 hours so 24+22 hours...</description>
      <pubDate>Mon, 22 Nov 2021 13:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781718#M249139</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2021-11-22T13:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate difference between two dates when one dat with time and another has only date v</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781727#M249143</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/245051"&gt;@Aayushi_17&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;the difference for one record is one day and 22 hours so 24+22 hours...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I am not following this. It seems to me the difference is 1 hour and 40 minutes. The difference between&amp;nbsp;&lt;SPAN&gt;2021-06-11T22:20 and&amp;nbsp;2021-06-12 is ... lets see, midnight on 2021-06-12 is the day after&amp;nbsp;2021-06-11T22:20, and it is 1 hour and 40 minutes between 2021-06-11T22:20 and midnight on 2021-06-12.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide more details, step-by-step about how you calculate your answer.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 14:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781727#M249143</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-22T14:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate difference between two dates when one dat with time and another has only date v</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781740#M249149</link>
      <description>&lt;P&gt;First some language clarification.&amp;nbsp; You appear to have character strings that you want to interpret as DATETIME values (not DATE values).&amp;nbsp; SAS stores date values as number of days. It stores datetime values as number of seconds.&amp;nbsp; The difference between two datetime values will be TIME values, not DATE values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So just convert your string into datetime values and then subtract.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  dt1=input(dtc_1,b8601dt20.);
  dt2=input(dtc_2,b8601dt20.);
  diff = dt2-dt1;
  format dt1 dt2 datetime19. diff time12.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the result&lt;/P&gt;
&lt;PRE&gt;Obs      DTC_1         DTC_2                   dt1                dt2      diff

 1  2021-06-11T22:20 2021-06-12 11JUN2021:22:20:00 12JUN2021:00:00:00   1:40:00
 2  2021-08-30T16:58 2021-10-05 30AUG2021:16:58:00 05OCT2021:00:00:00 847:02:00
 3  2021-10-05T07:17            05OCT2021:07:17:00                  .         .
 4  2021-10-07T15:14 2021-10-08 07OCT2021:15:14:00 08OCT2021:00:00:00   8:46:00
 5  2021-10-09T16:22 2021-10-10 09OCT2021:16:22:00 10OCT2021:00:00:00   7:38:00
 6  2021-08-30T09:54 2021-08-30 30AUG2021:09:54:00 30AUG2021:00:00:00  -9:54:00&lt;/PRE&gt;
&lt;P&gt;does not look much like your requested result.&amp;nbsp; How did you get the time intervals you posted? What datetime value did you think that a string like '2021-08-30' represents?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 16:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-difference-between-two-dates-when-one-dat-with/m-p/781740#M249149</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-22T16:06:58Z</dc:date>
    </item>
  </channel>
</rss>

