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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 62484 views
  • 5 likes
  • 4 in conversation