<?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 mysql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377826#M90745</link>
    <description>&lt;P&gt;what are you trying to do here, in words? &lt;SPAN class="short_text"&gt;&lt;SPAN class=""&gt;I do not know for the moment&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jul 2017 16:13:31 GMT</pubDate>
    <dc:creator>mansour_ibrahim</dc:creator>
    <dc:date>2017-07-20T16:13:31Z</dc:date>
    <item>
      <title>date mysql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377819#M90742</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have requests mysql, i want to translate in sas :&lt;/P&gt;&lt;P&gt;1/&amp;nbsp; date&amp;gt; DATE_FORMAT(now(), "%Y-%m-01")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i make this ==&amp;gt;&amp;gt; date&amp;gt; intnx('month',today(),0,'b') ; is't correct ???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2/ MOIS &amp;gt;= DATE_FORMAT( DATE_SUB( NOW( ) , INTERVAL 1 MONTH) , '%Y-%m-01');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i make this ===&amp;gt;&amp;gt; mois &amp;gt; INTNX('month',today(),1,'b'); is't correct ???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 15:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377819#M90742</guid>
      <dc:creator>mansour_ibrahim</dc:creator>
      <dc:date>2017-07-20T15:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: date mysql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377822#M90744</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121073"&gt;@mansour_ibrahim&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have requests mysql, i want to translate in sas :&lt;/P&gt;
&lt;P&gt;1/&amp;nbsp; date&amp;gt; DATE_FORMAT(now(), "%Y-%m-01")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i make this ==&amp;gt;&amp;gt; date&amp;gt; intnx('month',today(),0,'b') ; is't correct ???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2/ MOIS &amp;gt;= DATE_FORMAT( DATE_SUB( NOW( ) , INTERVAL 1 MONTH) , '%Y-%m-01');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i make this ===&amp;gt;&amp;gt; mois &amp;gt; INTNX('month',today(),1,'b'); is't correct ???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you getting the values you expect?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pretend we dont' know MYSQL, what are you trying to do here, in words?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 16:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377822#M90744</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-20T16:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: date mysql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377826#M90745</link>
      <description>&lt;P&gt;what are you trying to do here, in words? &lt;SPAN class="short_text"&gt;&lt;SPAN class=""&gt;I do not know for the moment&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 16:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377826#M90745</guid>
      <dc:creator>mansour_ibrahim</dc:creator>
      <dc:date>2017-07-20T16:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: date mysql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377979#M90798</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121073"&gt;@mansour_ibrahim&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;what are you trying to do here, in words? &lt;SPAN class="short_text"&gt;&lt;SPAN class=""&gt;I do not know for the moment&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then how will you know whether you have gotten the right answer?&lt;/P&gt;
&lt;P&gt;Perhaps you need to post a question on a MySQL site to find out the meaning of the original syntax?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 02:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377979#M90798</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-21T02:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: date mysql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377983#M90800</link>
      <description>&lt;P&gt;As best as I can tell from this man page &amp;nbsp;&lt;A href="https://www.w3schools.com/sql/func_mysql_date_format.asp" target="_blank"&gt;https://www.w3schools.com/sql/func_mysql_date_format.asp&lt;/A&gt; the meaning of DATE_FORMAT() is more like a FORMAT statement than like an actual function. &amp;nbsp;So something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select DATE_FORMAT(now(), "%Y-%m-01") as mydatevar
     , DATE_FORMAT( DATE_SUB( NOW( ) , INTERVAL 1 MONTH) , '%Y-%m-01') as mydatevar2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;would translate into creating a variable with today's date but with a format attached to it that displays it as if it was the first day of the month. &amp;nbsp;You could possible build such a format, but why not just use one of the existing date formats that does NOT display the day of the month so that it doesn't matter what the day of the month really is? &amp;nbsp;The DATE_SUB() function subtracts intevals dates so you need to use INTNX() to simulate that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select date() as mydatevar format=yymmd7.
     , intnx('month',date(),-1,'s') as mydatevar2 format=yymmd7.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it might just be easier to just set the value to the first day of the month instead then you could use the YYMMDDd10. format (the last D means to use dash as separator) to have it display that date in YYYY-MM-DD format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select intnx('month',date(),0,'b') as mydatevar format=yymmddd10.
     , intnx('month',date(),-1,'b') as mydatevar2 format=yymmddd10.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that you need to use a negative number in your INTNX() calls since DATE_SUB() means SUBTRACT. There is a separate function, DATE_ADD(), that is used to move forward in time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 03:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377983#M90800</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-21T03:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: date mysql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377986#M90801</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121073"&gt;@mansour_ibrahim&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;what are you trying to do here, in words? &lt;SPAN class="short_text"&gt;&lt;SPAN class=""&gt;I do not know for the moment&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Whenever I'd say that as a kid, my dad would respond, "If you don't know, who should?" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 02:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-mysql/m-p/377986#M90801</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-21T02:46:13Z</dc:date>
    </item>
  </channel>
</rss>

