<?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 convert date to datime in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/convert-date-to-datime/m-p/934047#M44912</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
PIT_day = intnx('day',(intnx('month',date(),-1,'e')),-2);
AUTH_DT = intnx('dtday',(intnx('dtmonth',datetime(),-0, 'b')),-3) +'20:00:00't ;
AUTH_DT2 = PIT_day +'20:00:00't ;
format pit_day date9. AUTH_DT2 auth_dt datetime19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The PIT_day and AUTH_DT gives the expected values.&lt;/P&gt;
&lt;P&gt;However, if I want to reuse the value of PIT_day like in AUTH_DT2, it does not give 29MAY2024:20:00:00&lt;/P&gt;
&lt;P&gt;How could we do that ?&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jun 2024 12:59:45 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2024-06-28T12:59:45Z</dc:date>
    <item>
      <title>convert date to datime</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/convert-date-to-datime/m-p/934047#M44912</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
PIT_day = intnx('day',(intnx('month',date(),-1,'e')),-2);
AUTH_DT = intnx('dtday',(intnx('dtmonth',datetime(),-0, 'b')),-3) +'20:00:00't ;
AUTH_DT2 = PIT_day +'20:00:00't ;
format pit_day date9. AUTH_DT2 auth_dt datetime19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The PIT_day and AUTH_DT gives the expected values.&lt;/P&gt;
&lt;P&gt;However, if I want to reuse the value of PIT_day like in AUTH_DT2, it does not give 29MAY2024:20:00:00&lt;/P&gt;
&lt;P&gt;How could we do that ?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2024 12:59:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/convert-date-to-datime/m-p/934047#M44912</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-06-28T12:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: convert date to datime</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/convert-date-to-datime/m-p/934049#M44913</link>
      <description>&lt;P&gt;This cannot work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;AUTH_DT2 = PIT_day +'20:00:00't ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS dates are counts of days, while times are counts of seconds; you are mixing apples and oranges here.&lt;/P&gt;
&lt;P&gt;Use the DHMS function instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;auth_dt2 = dhms(pit_day,20,0,0);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jun 2024 13:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/convert-date-to-datime/m-p/934049#M44913</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-06-28T13:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: convert date to datime</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/convert-date-to-datime/m-p/934050#M44914</link>
      <description>&lt;P&gt;If you want to convert a DATE value (number of days) into a DATETIME value (number of seconds) you could just multiply the value by the number of seconds in a day ('24:00:00't).&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datetime = date*'24:00:00't ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But SAS also has a function that does that.&amp;nbsp; DHMS(days,hours,minutes,seconds).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datetime = dhms(date,0,0,0);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also just create a datetime value to begin with.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PIT_dt = intnx('dtday',(intnx('dtmonth',datetime(),-1,'e')),-2);
format pit_dt datetime19.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jun 2024 13:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/convert-date-to-datime/m-p/934050#M44914</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-06-28T13:05:18Z</dc:date>
    </item>
  </channel>
</rss>

