<?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 Sql date format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sql-date-format/m-p/645240#M192856</link>
    <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to get the date value form a table using sql query. But I am getting&amp;nbsp; the following error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ERROR: ORACLE prepare error: ORA-00923: FROM keyword not found where expected. SQL&lt;BR /&gt;statement: SELECT ACCT.number as Acct_id,datepart(ACCT.DATE) AS DT format date9.,ACCT.Num,&lt;BR /&gt;Client.Name FROM ACCT,Client&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;connect to ORACLE (user="xxxx" password="xxxx" buffsize=5000 path=test);&lt;BR /&gt;CREATE TABLE sample AS&lt;BR /&gt;SELECT * FROM CONNECTION TO ORACLE&lt;BR /&gt;(&lt;BR /&gt;SELECT&lt;BR /&gt;ACCT.number as Acct_id,&lt;BR /&gt;datepart(ACCT.DATE) AS DT format date9.,&lt;BR /&gt;ACCT.Num,&lt;BR /&gt;Client.Name&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;FROM&lt;BR /&gt;ACCT,&lt;BR /&gt;Client&lt;/P&gt;&lt;P&gt;);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest if I am doing anything wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 May 2020 11:04:12 GMT</pubDate>
    <dc:creator>sanjay1</dc:creator>
    <dc:date>2020-05-05T11:04:12Z</dc:date>
    <item>
      <title>Sql date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sql-date-format/m-p/645240#M192856</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to get the date value form a table using sql query. But I am getting&amp;nbsp; the following error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ERROR: ORACLE prepare error: ORA-00923: FROM keyword not found where expected. SQL&lt;BR /&gt;statement: SELECT ACCT.number as Acct_id,datepart(ACCT.DATE) AS DT format date9.,ACCT.Num,&lt;BR /&gt;Client.Name FROM ACCT,Client&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;connect to ORACLE (user="xxxx" password="xxxx" buffsize=5000 path=test);&lt;BR /&gt;CREATE TABLE sample AS&lt;BR /&gt;SELECT * FROM CONNECTION TO ORACLE&lt;BR /&gt;(&lt;BR /&gt;SELECT&lt;BR /&gt;ACCT.number as Acct_id,&lt;BR /&gt;datepart(ACCT.DATE) AS DT format date9.,&lt;BR /&gt;ACCT.Num,&lt;BR /&gt;Client.Name&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;FROM&lt;BR /&gt;ACCT,&lt;BR /&gt;Client&lt;/P&gt;&lt;P&gt;);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest if I am doing anything wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 11:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sql-date-format/m-p/645240#M192856</guid>
      <dc:creator>sanjay1</dc:creator>
      <dc:date>2020-05-05T11:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sql date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sql-date-format/m-p/645264#M192864</link>
      <description>&lt;P&gt;The Oracle DATEPART() function works differently than the SAS DATEPART():&amp;nbsp;&lt;A href="https://docs.oracle.com/cd/E57185_01/ESBTR/mdx_datepart.html" target="_blank" rel="noopener"&gt;https://docs.oracle.com/cd/E57185_01/ESBTR/mdx_datepart.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, Oracle will (most likely) not understand DATE9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before using explicit passthrough to database system X, you need to have sufficient knowledge of the peculiarities of DBMS X. If in doubt, ask your local Oracle admins.&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 12:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sql-date-format/m-p/645264#M192864</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-05T12:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sql date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sql-date-format/m-p/645272#M192867</link>
      <description>&lt;P&gt;Your code has syntax errors. You are using the "Pass-Through" feature. "Format's" are exclusive features of SAS, they will not work inside the "Pass-Through" block.&lt;/P&gt;&lt;P&gt;See&amp;nbsp;"&lt;A href="https://documentation.sas.com/?docsetId=acreldb&amp;amp;docsetTarget=n0dbrcxwx9q7non1wvcw2l54xa3m.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;Pass-Through&lt;/A&gt;"&lt;BR /&gt;In addition, oracle has no data type "date", only "date-time", but if your SAS is configured correctly, the SAS itself does the necessary conversions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to ORACLE (user="xxxx" password="xxxx" buffsize=5000 path=test);
CREATE TABLE sample AS
SELECT 
 Acct_id, 
datepart(DATE) as DT format date9., 
Num,
Name
 FROM CONNECTION TO ORACLE
(
SELECT
ACCT.number as Acct_id, ACCT.DATE, ACCT.Num, Client.Name
FROM ACCT, Client
);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 May 2020 12:38:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sql-date-format/m-p/645272#M192867</guid>
      <dc:creator>dcmacedo</dc:creator>
      <dc:date>2020-05-05T12:38:40Z</dc:date>
    </item>
  </channel>
</rss>

