<?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 days between datetime value and date9 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/days-between-datetime-value-and-date9/m-p/765161#M80962</link>
    <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i need to calculate this within a proc sql querym i've tried a number of things to get it right. i see the problem, since when i do datepart(sampledate) it returns an integer, but datepart(filedate) returns 0 so the intck calculation is way off. how do i get datetime and date9 to play well together in the query?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filedate = 07JUN1997 (date9.)&lt;/P&gt;&lt;P&gt;sampledate = 30AUG2021:08:00:00.0000000 (datetime26.7)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;

create table work.result as

select

intck('dtday',sampledate,filedate)

from table&lt;/PRE&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>Tue, 31 Aug 2021 19:44:40 GMT</pubDate>
    <dc:creator>ryanb0001</dc:creator>
    <dc:date>2021-08-31T19:44:40Z</dc:date>
    <item>
      <title>days between datetime value and date9</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/days-between-datetime-value-and-date9/m-p/765161#M80962</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i need to calculate this within a proc sql querym i've tried a number of things to get it right. i see the problem, since when i do datepart(sampledate) it returns an integer, but datepart(filedate) returns 0 so the intck calculation is way off. how do i get datetime and date9 to play well together in the query?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filedate = 07JUN1997 (date9.)&lt;/P&gt;&lt;P&gt;sampledate = 30AUG2021:08:00:00.0000000 (datetime26.7)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;

create table work.result as

select

intck('dtday',sampledate,filedate)

from table&lt;/PRE&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>Tue, 31 Aug 2021 19:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/days-between-datetime-value-and-date9/m-p/765161#M80962</guid>
      <dc:creator>ryanb0001</dc:creator>
      <dc:date>2021-08-31T19:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: days between datetime value and date9</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/days-between-datetime-value-and-date9/m-p/765162#M80963</link>
      <description>&lt;P&gt;Both variables have to be the same units ... in one case, the variable that is DATE9. is measured internally in units of days; the variable that is DATETIME26.7 is measured in units of seconds.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have to convert the DATETIME26.7 variable to days, or alternatively convert the DATE9. variable to seconds, and then you can do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;intck('day',datepart(sampledate),filedate)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The datepart function converts datetime values measured in seconds to date values measured in days, and then the arithmetic works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 19:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/days-between-datetime-value-and-date9/m-p/765162#M80963</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-31T19:59:07Z</dc:date>
    </item>
  </channel>
</rss>

