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