<?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 Datetime display in datset not showing actual date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Datetime-display-in-datset-not-showing-actual-date/m-p/786231#M250993</link>
    <description>&lt;PRE&gt;data citiday(keep=SNYDJCM date);
set sashelp.citiday;
if date &amp;lt;="28feb1988"d;
format date datetime.;
/*format date datetime20.1;*/
run;&lt;/PRE&gt;
&lt;P&gt;/*01JAN60:02:50:27 using datetime. &lt;BR /&gt;prefer to get the actual datetime not 1960&lt;BR /&gt;Ieally I want the date in mmddyy10 with the timestamp&lt;BR /&gt;however I can settle for the date9 format with the timestamp*/&lt;/P&gt;</description>
    <pubDate>Wed, 15 Dec 2021 20:27:26 GMT</pubDate>
    <dc:creator>Q1983</dc:creator>
    <dc:date>2021-12-15T20:27:26Z</dc:date>
    <item>
      <title>Datetime display in datset not showing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-display-in-datset-not-showing-actual-date/m-p/786231#M250993</link>
      <description>&lt;PRE&gt;data citiday(keep=SNYDJCM date);
set sashelp.citiday;
if date &amp;lt;="28feb1988"d;
format date datetime.;
/*format date datetime20.1;*/
run;&lt;/PRE&gt;
&lt;P&gt;/*01JAN60:02:50:27 using datetime. &lt;BR /&gt;prefer to get the actual datetime not 1960&lt;BR /&gt;Ieally I want the date in mmddyy10 with the timestamp&lt;BR /&gt;however I can settle for the date9 format with the timestamp*/&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 20:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-display-in-datset-not-showing-actual-date/m-p/786231#M250993</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-12-15T20:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime display in datset not showing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-display-in-datset-not-showing-actual-date/m-p/786236#M250997</link>
      <description>&lt;P&gt;Dates in SAS are measured in days, time and Datetimes in seconds. So if you apply a datetime format to a date value you typically get something in 1960 or so as the number days is short by about 60*60*24 .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want a date time for the date use the DHMS function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dt = dhms(date,0,0,0);&lt;/P&gt;
&lt;P&gt;and apply the datetime format to the DT variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 21:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-display-in-datset-not-showing-actual-date/m-p/786236#M250997</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-15T21:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime display in datset not showing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-display-in-datset-not-showing-actual-date/m-p/786250#M251005</link>
      <description>&lt;P&gt;Your code&lt;STRONG&gt; IS&lt;/STRONG&gt; showing the actual date.&amp;nbsp; You gave it a number of seconds that was under 3 hours into the first day of 1960 so it is properly showing the date as the first of January in 1960.&amp;nbsp;&amp;nbsp;SAS stores dates as number of days since&amp;nbsp; 1960 and datetime values as number of seconds since 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the DATETIME of execution use the DATETIME() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't recommend displaying dates in either MDY or DMY order, either one will confuse 50% of your audience. Either use YMD order of d-MON-y.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;312   data now;
313     today = date();
314     now = datetime();
315     put 'TODAY ' / today comma12. / today date9. / today yymmdd10. / today mmddyy10. / today ddmmyy10.
316      // 'NOW ' / now comma17. / now datetime19. / now mdyampm. / now e8601dt.
317     ;
318   run;

TODAY
      22,629
15DEC2021
2021-12-15
12/15/2021
15/12/2021

NOW
    1,955,222,463
 15DEC2021:21:21:03
12/15/2021  9:21 PM
2021-12-15T21:21:03
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 02:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-display-in-datset-not-showing-actual-date/m-p/786250#M251005</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-16T02:32:19Z</dc:date>
    </item>
  </channel>
</rss>

