<?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: Converting character date to  &amp;quot; DATETIME20.&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334022#M75369</link>
    <description>&lt;P&gt;You're almost there. You have to convert it from date (days since 1Jan1960) to datetime (seconds from…). The&amp;nbsp;&lt;EM&gt;dhms&lt;/EM&gt; function does this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
date1 = '10/15/2017';
run;
 
 
proc sql;
create table test2 as
select
dhms(input(date1, MMDDYY10.), 0, 0, 0) AS date2 format = DATETIME20.
from test
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 18 Feb 2017 03:53:39 GMT</pubDate>
    <dc:creator>LaurieF</dc:creator>
    <dc:date>2017-02-18T03:53:39Z</dc:date>
    <item>
      <title>Converting character date to  " DATETIME20."</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334021#M75368</link>
      <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need help with generating charcter date like below to DATE format to insert into ORacle Database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the below way in &amp;nbsp;EG &amp;amp; got it to the default date of SAS than the original date. where i am doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;date1 = '10/15/2017';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table test2 as&lt;BR /&gt;select&lt;BR /&gt;input(date1, MMDDYY10.) AS date2 format = DATETIME20.&lt;BR /&gt;from test&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ana&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 03:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334021#M75368</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2017-02-18T03:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character date to  " DATETIME20."</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334022#M75369</link>
      <description>&lt;P&gt;You're almost there. You have to convert it from date (days since 1Jan1960) to datetime (seconds from…). The&amp;nbsp;&lt;EM&gt;dhms&lt;/EM&gt; function does this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
date1 = '10/15/2017';
run;
 
 
proc sql;
create table test2 as
select
dhms(input(date1, MMDDYY10.), 0, 0, 0) AS date2 format = DATETIME20.
from test
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Feb 2017 03:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334022#M75369</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-02-18T03:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character date to  " DATETIME20."</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334023#M75370</link>
      <description>&lt;P&gt;Thank you. I tried below ways too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table test2 as&lt;BR /&gt;select&lt;BR /&gt;input(date1, MMDDYY10.) * 86400 AS date2 format = DATETIME20. ,&lt;BR /&gt;input(date1,anydtdtm20.) AS date3 format = DATETIME. ,&lt;BR /&gt;dhms(input(date1, MMDDYY10.), 0, 0, 0) AS date4 format = DATETIME20.&lt;BR /&gt;from test&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All date2, date3, date4 were giving me results like - &amp;nbsp;&lt;/P&gt;&lt;P&gt;15OCT2017:00:00:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15OCT17:00:00:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15OCT2017:00:00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for "9/20/2015 12:00:00 AM" format .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ana&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 04:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334023#M75370</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2017-02-18T04:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character date to  " DATETIME20."</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334024#M75371</link>
      <description>&lt;P&gt;Oh, OK. What happens when you pass it to Oracle once you've done that? As long as the variable's format is set to &lt;EM&gt;datetime&lt;/EM&gt; and the value is in seconds, the Oracle engine should do anything it needs to do for you.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 04:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334024#M75371</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-02-18T04:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character date to  " DATETIME20."</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334026#M75372</link>
      <description>&lt;P&gt;Hi Laurie,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are right. Oracle converted to the format i wanted internally. Thanks for the suggestion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ana&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 04:15:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-date-to-quot-DATETIME20-quot/m-p/334026#M75372</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2017-02-18T04:15:34Z</dc:date>
    </item>
  </channel>
</rss>

