<?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: proc sql and date format in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29851#M7015</link>
    <description>try this:&lt;BR /&gt;
&lt;BR /&gt;
where date_var between '01May2008:0:0'dt and '01Dec2008:0:0'dt.  &lt;BR /&gt;
&lt;BR /&gt;
That's what I have to do to query oracle tables for date values.</description>
    <pubDate>Tue, 01 Jun 2010 18:26:54 GMT</pubDate>
    <dc:creator>DBailey</dc:creator>
    <dc:date>2010-06-01T18:26:54Z</dc:date>
    <item>
      <title>proc sql and date format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29849#M7013</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am trying to query using PROC SQL and conditions on the dates (my date variable is DATE9. format) like this:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select ____ from &lt;BR /&gt;
&lt;B&gt;where date_var between '01MAY2008' and '01DEC2008'&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
but I am getting an error message like this: "The syntax of the string representation of a datetime value is incorrect"&lt;BR /&gt;
&lt;BR /&gt;
And I also tried which did not work.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;where date_var between '01MAY2008'd and '01DEC2008'd&lt;/B&gt; &lt;BR /&gt;
&lt;BR /&gt;
and &lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;where date_var between '01MAY2008'date9. and '01DEC2008'date9.&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
and the error message here is &lt;BR /&gt;
ERROR: CLI describe error: [IBM][CLI Driver][DB2/AIX64] SQL0104N  An unexpected token "d" was found following "between '01MAY2008'".  Expected tokens may include:  "&lt;ROW_VALUE_CONSTRUCTOR&gt;".  SQLSTATE=42601&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Could anyone advise? Thank you!&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: SAS_user_n

Message was edited by: SAS_user_n&lt;/ROW_VALUE_CONSTRUCTOR&gt;</description>
      <pubDate>Tue, 01 Jun 2010 17:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29849#M7013</guid>
      <dc:creator>SAS_user_n</dc:creator>
      <dc:date>2010-06-01T17:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and date format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29850#M7014</link>
      <description>You should show the entire query that failed.&lt;BR /&gt;
&lt;BR /&gt;
It looks like you may be using the SQL Pass-thru to DB2.  If so, then you need to look at the SAS/Access documentation for DB2 to see how to pass a date (it's different, depending on the DB2 host).&lt;BR /&gt;
&lt;BR /&gt;
If you converted your query to the LIBNAME style, the SAS translator should convert the 'ddmmmyyyy'd style to the appropriate internal style for DB2.</description>
      <pubDate>Tue, 01 Jun 2010 18:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29850#M7014</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-06-01T18:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and date format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29851#M7015</link>
      <description>try this:&lt;BR /&gt;
&lt;BR /&gt;
where date_var between '01May2008:0:0'dt and '01Dec2008:0:0'dt.  &lt;BR /&gt;
&lt;BR /&gt;
That's what I have to do to query oracle tables for date values.</description>
      <pubDate>Tue, 01 Jun 2010 18:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29851#M7015</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2010-06-01T18:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and date format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29852#M7016</link>
      <description>Thank you for your reply. Here is my entire query.&lt;BR /&gt;
Could you shed some more light? Thank you.&lt;BR /&gt;
&lt;BR /&gt;
==========================================&lt;BR /&gt;
proc sql outobs=10;&lt;BR /&gt;
connect to db2 (database=%sysget(DB2DBDFT));&lt;BR /&gt;
create table temp as&lt;BR /&gt;
    select * from connection to db2&lt;BR /&gt;
	( select DATE_VAR_1 &lt;BR /&gt;
			, VAR_2&lt;BR /&gt;
			, VAR_3&lt;BR /&gt;
&lt;BR /&gt;
	from  XYZ.TABLE      &lt;BR /&gt;
	&lt;BR /&gt;
&lt;B&gt;	where DATE_VAR_1 between '01MAY2008'd and '30NOV2008'd&lt;/B&gt; &lt;BR /&gt;
	)   ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: SAS_user_n&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: SAS_user_n

Message was edited by: SAS_user_n</description>
      <pubDate>Tue, 01 Jun 2010 18:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29852#M7016</guid>
      <dc:creator>SAS_user_n</dc:creator>
      <dc:date>2010-06-01T18:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and date format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29853#M7017</link>
      <description>Thanks for your reply. I tried your suggestion but since mine is db2, the suggestion did not work......</description>
      <pubDate>Tue, 01 Jun 2010 18:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29853#M7017</guid>
      <dc:creator>SAS_user_n</dc:creator>
      <dc:date>2010-06-01T18:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and date format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29854#M7018</link>
      <description>The WHERE clause is being shipped directly to DB2; SAS does not interpret it.  You have to specify the date literals using the DB2 conventions.  For that, you need a DB2 manual or guru.  (I don't use DB2, but recognize those symptoms).</description>
      <pubDate>Tue, 01 Jun 2010 19:45:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29854#M7018</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-06-01T19:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and date format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29855#M7019</link>
      <description>didn't realize you were making a connection in that manner.&lt;BR /&gt;
&lt;BR /&gt;
I think the ISO default for DB2 is yyyy-mm-dd.</description>
      <pubDate>Tue, 01 Jun 2010 20:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-and-date-format/m-p/29855#M7019</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2010-06-01T20:53:26Z</dc:date>
    </item>
  </channel>
</rss>

