<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Datetime/m-p/788804#M252307</link>
    <description>&lt;P&gt;Don't apply a format to a date, datetime or time macro-variable if you want to use in calculations.&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let wanted = %sysfunc(intnx(dtyear, %sysfunc(datetime()), -1, s), e8601dt24.3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or if you need the variable date (bad name for a variable not containing a date, but a datetime-value):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date = %sysfunc(datetime());
%let want = %sysfunc(intnx(dtyear, &amp;amp;date., -1, s), e8601dt24.3);
%put &amp;amp;=want;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Jan 2022 06:11:17 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-01-07T06:11:17Z</dc:date>
    <item>
      <title>Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime/m-p/788796#M252301</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I've a datetime value which is&lt;BR /&gt;Date = %sysfunc(datetime(), e8601dt24.3);&lt;BR /&gt;output : 2022-01-07T10:38:49.095&lt;BR /&gt;I would like to subtract 365 days from Date Variable i.e a year.&lt;BR /&gt;The wanted Date Variable should look like this&lt;BR /&gt;2021-01-07T10.38.49.095&lt;BR /&gt;Can anyone please help me on achieving this. Thanks in advance.</description>
      <pubDate>Fri, 07 Jan 2022 05:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime/m-p/788796#M252301</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2022-01-07T05:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime/m-p/788804#M252307</link>
      <description>&lt;P&gt;Don't apply a format to a date, datetime or time macro-variable if you want to use in calculations.&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let wanted = %sysfunc(intnx(dtyear, %sysfunc(datetime()), -1, s), e8601dt24.3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or if you need the variable date (bad name for a variable not containing a date, but a datetime-value):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date = %sysfunc(datetime());
%let want = %sysfunc(intnx(dtyear, &amp;amp;date., -1, s), e8601dt24.3);
%put &amp;amp;=want;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jan 2022 06:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime/m-p/788804#M252307</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-01-07T06:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime/m-p/788806#M252309</link>
      <description>Thank you veryy muchh. This looks good and it is working.</description>
      <pubDate>Fri, 07 Jan 2022 06:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime/m-p/788806#M252309</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2022-01-07T06:43:55Z</dc:date>
    </item>
  </channel>
</rss>

