<?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 Query in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-Query/m-p/317093#M69372</link>
    <description>&lt;P&gt;What are you expecting for the result?&lt;/P&gt;
&lt;P&gt;Date values are number of days from 1 Jan 1960&lt;/P&gt;
&lt;P&gt;Datetime values are number of seconds from midnight 1 Jan 1960.&lt;/P&gt;
&lt;P&gt;If you want a datetime value you need to do something to turn a date into datetime.&lt;/P&gt;
&lt;P&gt;Perhaps this is close to what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%LET RUNDATE = 01OCT2016;

DATA _NULL_;
CALL SYMPUT("PERIOD1",PUT(INTNX('MONTH',"&amp;amp;RUNDATE"d,-1,'E'),DATE9.));
CALL SYMPUT("PERIOD2",PUT(INTNX('dtMONTH',"&amp;amp;RUNDATE 00:00:00"dt,-1,'E'),DATETIME24.));
RUN;

%PUT &amp;amp;PERIOD1;
%PUT &amp;amp;PERIOD2;
&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Dec 2016 18:12:15 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-12-06T18:12:15Z</dc:date>
    <item>
      <title>Date Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Query/m-p/317092#M69371</link>
      <description>&lt;P&gt;In the following code, i can get the answer for period1, but why I can't get the desired period for period2 but only got date back to 1960. &amp;nbsp;Please help, thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%LET RUNDATE = '01OCT2016'D;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;BR /&gt;CALL SYMPUT("PERIOD1",PUT(INTNX('MONTH',&amp;amp;RUNDATE,-1,'E'),DATE9.));&lt;BR /&gt;CALL SYMPUT("PERIOD2",PUT(INTNX('MONTH',&amp;amp;RUNDATE,-1,'E'),DATETIME24.));&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%PUT &amp;amp;PERIOD1;&lt;BR /&gt;%PUT &amp;amp;PERIOD2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 18:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Query/m-p/317092#M69371</guid>
      <dc:creator>scb</dc:creator>
      <dc:date>2016-12-06T18:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Date Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Query/m-p/317093#M69372</link>
      <description>&lt;P&gt;What are you expecting for the result?&lt;/P&gt;
&lt;P&gt;Date values are number of days from 1 Jan 1960&lt;/P&gt;
&lt;P&gt;Datetime values are number of seconds from midnight 1 Jan 1960.&lt;/P&gt;
&lt;P&gt;If you want a datetime value you need to do something to turn a date into datetime.&lt;/P&gt;
&lt;P&gt;Perhaps this is close to what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%LET RUNDATE = 01OCT2016;

DATA _NULL_;
CALL SYMPUT("PERIOD1",PUT(INTNX('MONTH',"&amp;amp;RUNDATE"d,-1,'E'),DATE9.));
CALL SYMPUT("PERIOD2",PUT(INTNX('dtMONTH',"&amp;amp;RUNDATE 00:00:00"dt,-1,'E'),DATETIME24.));
RUN;

%PUT &amp;amp;PERIOD1;
%PUT &amp;amp;PERIOD2;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Dec 2016 18:12:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Query/m-p/317093#M69372</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-12-06T18:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Date Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Query/m-p/317226#M69416</link>
      <description>&lt;P&gt;It almost got what I wanted; but may i know why the datetime was 30SEP2016:23:59:59 instead of 30SEP2016:00:00:00? Any idea why?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 07:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Query/m-p/317226#M69416</guid>
      <dc:creator>scb</dc:creator>
      <dc:date>2016-12-07T07:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Date Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Query/m-p/317365#M69477</link>
      <description>&lt;P&gt;Your -1 subtracts one second. I left that in because you never showed what you expected the result to actually be.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 16:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Query/m-p/317365#M69477</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-12-07T16:25:47Z</dc:date>
    </item>
  </channel>
</rss>

