<?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: Datetime format question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Datetime-format-question/m-p/823038#M324989</link>
    <description>&lt;P&gt;If you want the date for pervious month, beinning of the day, then as pointed out by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;, DTMonth should be used instead of Month in the INTNX function. If the todays date is being used, then the code will like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;&lt;BR /&gt;format my_date nldatm.;
my_date = INTNX('DTMONTH',datetime(),-1,'B') ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Jul 2022 00:50:11 GMT</pubDate>
    <dc:creator>Sajid01</dc:creator>
    <dc:date>2022-07-13T00:50:11Z</dc:date>
    <item>
      <title>Datetime format question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-format-question/m-p/822966#M324962</link>
      <description>&lt;PRE&gt;data test;
my_date = INTNX('MONTH',&amp;amp;tday,-1,'B') ;
format my_date nldatm.;
run;&lt;/PRE&gt;
&lt;P&gt;The above code returns&amp;nbsp;01Jan1960:06:19:57 and not the current beginning of last month.&amp;nbsp; In this case I want 01Jun2022:00:00: etc..........&amp;nbsp; I need this to use it in a dataset because the field in the dataset uses datetime&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 18:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-format-question/m-p/822966#M324962</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2022-07-12T18:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime format question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-format-question/m-p/822968#M324963</link>
      <description>&lt;P&gt;If you want to increment datetime values the interval is DTmonth or DTyear or DTday. See the pattern?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since dates are counts of days and datetimes are seconds the intervals must be different.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 18:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-format-question/m-p/822968#M324963</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-12T18:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime format question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-format-question/m-p/822969#M324964</link>
      <description>&lt;P&gt;What does the macro variable TDAY have in it?&lt;/P&gt;
&lt;P&gt;Your code is treating it as a DATE in the assignment statement, since the MONTH interval is for DATE values.&lt;/P&gt;
&lt;P&gt;But then you are attaching a DATETIME format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the value of &amp;amp;TDAY is a datetime value (number of seconds since 1960) then you want to use the DTMONTH interval in the INTNX() function call.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 18:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-format-question/m-p/822969#M324964</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-12T18:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime format question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-format-question/m-p/823038#M324989</link>
      <description>&lt;P&gt;If you want the date for pervious month, beinning of the day, then as pointed out by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;, DTMonth should be used instead of Month in the INTNX function. If the todays date is being used, then the code will like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;&lt;BR /&gt;format my_date nldatm.;
my_date = INTNX('DTMONTH',datetime(),-1,'B') ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jul 2022 00:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-format-question/m-p/823038#M324989</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-07-13T00:50:11Z</dc:date>
    </item>
  </channel>
</rss>

