BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
scb
Obsidian | Level 7 scb
Obsidian | Level 7

May I know how to get the "Today Datetime" in current datetime instead of 1960? Thanks.


data _null_;

x=today();

y=x;
z=x;

 

format y date9.;
format z datetime20.;

 

put "Unformatted:" x "Formatted:" y "Today Datetime:" z;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Criptic
Lapis Lazuli | Level 10
data _null_;
 x = today();
 format x ddmmyy10.;
 y = datetime();
 format y datetime20.;
 put "Formatted day: " x " , formatted datetime: " y;
run;

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

today() delivers a date, which is the count of days from 1960-01-01.

A datetime format expects a count of seconds from 1960-01-01T00:00:00.

That's why you get a timestamp from 1960-01-01.

Either use the datetime() function, or a date format.

Criptic
Lapis Lazuli | Level 10
data _null_;
 x = today();
 format x ddmmyy10.;
 y = datetime();
 format y datetime20.;
 put "Formatted day: " x " , formatted datetime: " y;
run;
Rohit2RaiAxis
Fluorite | Level 6
You can multiply the date you get from today() by 86400 to get DD:MM:YYYY:00:00:00

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 59352 views
  • 5 likes
  • 4 in conversation