<?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: difference between two dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665792#M199121</link>
    <description>&lt;P&gt;According to format you have a daytime variably.&lt;/P&gt;
&lt;P&gt;You can get the date using function&amp;nbsp;&lt;STRONG&gt;datepart&lt;/STRONG&gt;(&amp;lt;daytime variable&amp;gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having two dates calculate:&lt;/P&gt;
&lt;P&gt;- days = date2 - date1;&lt;/P&gt;
&lt;P&gt;- months = intck('month', date1, date2);&lt;/P&gt;
&lt;P&gt;- weeks can be calculated as days/7 or by using intck('week', date1, date2);&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jun 2020 14:05:22 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2020-06-29T14:05:22Z</dc:date>
    <item>
      <title>difference between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665788#M199119</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my boss wants to know how long does a therapy last. This means the difference between the start date and end date. That can be days, weeks or months. The format is ddmmmyy:hh:mm:ss. And he wants to see the days, weeks and months of the therapy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I solve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Caro&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 13:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665788#M199119</guid>
      <dc:creator>Caro17</dc:creator>
      <dc:date>2020-06-29T13:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: difference between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665792#M199121</link>
      <description>&lt;P&gt;According to format you have a daytime variably.&lt;/P&gt;
&lt;P&gt;You can get the date using function&amp;nbsp;&lt;STRONG&gt;datepart&lt;/STRONG&gt;(&amp;lt;daytime variable&amp;gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having two dates calculate:&lt;/P&gt;
&lt;P&gt;- days = date2 - date1;&lt;/P&gt;
&lt;P&gt;- months = intck('month', date1, date2);&lt;/P&gt;
&lt;P&gt;- weeks can be calculated as days/7 or by using intck('week', date1, date2);&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 14:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665792#M199121</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-06-29T14:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: difference between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665794#M199122</link>
      <description>&lt;P&gt;Is your date a actual SAS datetime variable or something character?&lt;/P&gt;
&lt;P&gt;You may also want to provide some example of what your data looks like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS INTCK function will return the number of intervals between two SAS date, time or datetime variables&lt;/P&gt;
&lt;P&gt;You could get the number of days between two datetime values with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;days = intck('dtday',firstdt, seconddt)&lt;/P&gt;
&lt;P&gt;weeks =intck('dtweek',firstdt, seconddt)&lt;/P&gt;
&lt;P&gt;months=intck('dtmonth',firstdt, seconddt)&lt;/P&gt;
&lt;P&gt;but the values would have to be SAS datetime values.&lt;/P&gt;
&lt;P&gt;Or use dates and the interval in the function of 'day' 'week' or 'month'&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 14:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665794#M199122</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-29T14:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: difference between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665806#M199129</link>
      <description>With the days I get between 0 and 31536000 days. That means there must be also weeks and months. But I get nothing with weeks and months.&lt;BR /&gt;&lt;BR /&gt;data datdif&lt;BR /&gt;set therapy&lt;BR /&gt;start = datepart(start);&lt;BR /&gt;end = datepart(end);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data datdif;&lt;BR /&gt;set therapy&lt;BR /&gt;days = end - start;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc freq data = datdif; tables days; run;&lt;BR /&gt;&lt;BR /&gt;data datdif;&lt;BR /&gt;set therapy;&lt;BR /&gt;weeks = intck('week', start, end);&lt;BR /&gt;&lt;BR /&gt;proc freq data = datdif; tables weeks; run;&lt;BR /&gt;&lt;BR /&gt;data datdif;&lt;BR /&gt;set therapy;&lt;BR /&gt;months = intck('month', start, end);&lt;BR /&gt;&lt;BR /&gt;proc freq data = datdif; tables months; run;</description>
      <pubDate>Mon, 29 Jun 2020 14:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665806#M199129</guid>
      <dc:creator>Caro17</dc:creator>
      <dc:date>2020-06-29T14:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: difference between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665809#M199131</link>
      <description>&lt;P&gt;Do it all in one step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datdif
set therapy
start = datepart(start);
end = datepart(end);
days = end - start;&lt;BR /&gt;&lt;SPAN&gt;weeks = intck('week', start, end);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;months = intck('month', start, end);&lt;/SPAN&gt;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;proc freq data = datdif; &lt;BR /&gt;  tables days weeks months; &lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jun 2020 14:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/difference-between-two-dates/m-p/665809#M199131</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-06-29T14:58:48Z</dc:date>
    </item>
  </channel>
</rss>

