<?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: Date Format 01JAN2023 to 2023-01-01 Using SQL in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867516#M42677</link>
    <description>&lt;P&gt;Thanks for the response. I did try this too, but I got this error:&lt;/P&gt;&lt;P&gt;Syntax error: expected something between a string or a Unicode character literal and the word 'd'.&lt;/P&gt;</description>
    <pubDate>Fri, 31 Mar 2023 17:17:00 GMT</pubDate>
    <dc:creator>paulskie08</dc:creator>
    <dc:date>2023-03-31T17:17:00Z</dc:date>
    <item>
      <title>Date Format 01JAN2023 to 2023-01-01 Using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867511#M42674</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First off, I am very new to SAS and SQL. I am trying to convert the date column on my table from 01JAN2023 to 2023-01-01 on my PROC SQL statement but I keep on getting an error message. I tried the FORMAT and CONVERT options but no go. Here's how I'm doing it:&lt;/P&gt;&lt;P&gt;Select query_date, query_type&lt;/P&gt;&lt;P&gt;from call_database&lt;/P&gt;&lt;P&gt;where query_date &amp;gt;= '01JAN2023'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What should be the correct format for this statement? TIA!&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 17:10:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867511#M42674</guid>
      <dc:creator>paulskie08</dc:creator>
      <dc:date>2023-03-31T17:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format 01JAN2023 to 2023-01-01 Using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867514#M42675</link>
      <description>&lt;P&gt;For the WHERE clause, you need to use a valid&amp;nbsp;&lt;U&gt;date literal&lt;/U&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'01jan2023'&lt;FONT color="#FF0000"&gt;d&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Mar 2023 17:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867514#M42675</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-31T17:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format 01JAN2023 to 2023-01-01 Using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867515#M42676</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If all you want is to use the WHERE statement properly in SQL for this problem, use this (assuming query_date is a numeric variable that is an actual SAS date value).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where query_date &amp;gt;= '01JAN2023'd&lt;/CODE&gt;&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;
&lt;P&gt;What are typical values of QUERY_DATE?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, this seems to have nothing to do with your title, and I get the feeling that somewhere along the way, the question in the title is relevant, but I can't see right now what the relevance is.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 17:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867515#M42676</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-31T17:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format 01JAN2023 to 2023-01-01 Using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867516#M42677</link>
      <description>&lt;P&gt;Thanks for the response. I did try this too, but I got this error:&lt;/P&gt;&lt;P&gt;Syntax error: expected something between a string or a Unicode character literal and the word 'd'.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 17:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867516#M42677</guid>
      <dc:creator>paulskie08</dc:creator>
      <dc:date>2023-03-31T17:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format 01JAN2023 to 2023-01-01 Using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867518#M42678</link>
      <description>&lt;P&gt;Show us the complete log for this PROC SQL. That's &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;all&lt;/STRONG&gt; &lt;/FONT&gt;of the log for PROC SQL, every single line in the log for PROC SQL, not just the error messages. Never show us error messages only and expect us to know what happened.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 17:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867518#M42678</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-31T17:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format 01JAN2023 to 2023-01-01 Using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867519#M42679</link>
      <description>&lt;P&gt;I hovered over the query_date variable and it's a SAS date value.&lt;/P&gt;&lt;P&gt;All the values under query_date are&amp;nbsp; in the same format (i,e, 29JUL2021, 18MAY2021, 01SEP2022)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was initially trying to have the query_date output as 2023-01-01, but as long as I can show that all the dates are equal or greater than 01JAN2023, I should be good. Sorry if I didn't word it properly.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 17:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/867519#M42679</guid>
      <dc:creator>paulskie08</dc:creator>
      <dc:date>2023-03-31T17:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format 01JAN2023 to 2023-01-01 Using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/868013#M42701</link>
      <description>&lt;P&gt;Thank you, Paige. For some reason, it was an issue with the column name. I renamed the column and the syntax worked.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 15:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/868013#M42701</guid>
      <dc:creator>paulskie08</dc:creator>
      <dc:date>2023-04-04T15:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format 01JAN2023 to 2023-01-01 Using SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/868020#M42705</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/441423"&gt;@paulskie08&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I hovered over the query_date variable and it's a SAS date value.&lt;/P&gt;
&lt;P&gt;All the values under query_date are&amp;nbsp; in the same format (i,e, 29JUL2021, 18MAY2021, 01SEP2022)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was initially trying to have the query_date output as 2023-01-01, but as long as I can show that all the dates are equal or greater than 01JAN2023, I should be good. Sorry if I didn't word it properly.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A FORMAT in SAS is just instructions for how to convert the values stored in the variable into text.&amp;nbsp;The format attached to the variable is independent of the values stored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A data value in SAS is a number representing the number of days since the start of 1960.&amp;nbsp; If you display it using the DATE9. format it will look like 29JUL2021.&amp;nbsp; If you display it with the YYMMDD10. format it will look like 2023-07-29.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1440  data _null_;
1441   date='29JUL2023'd ;
1442   put date= comma12. +1 date date9. +1 date yymmdd10. ;
1443  run;

date=23,220  29JUL2023 2023-07-29
&lt;/PRE&gt;
&lt;P&gt;In SQL if you want to attach a format to variable use the FORMAT= option after the variable definition.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table want as 
  select id, datevar format=yymmdd10.
  from have
;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Apr 2023 16:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format-01JAN2023-to-2023-01-01-Using-SQL/m-p/868020#M42705</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-04T16:27:29Z</dc:date>
    </item>
  </channel>
</rss>

