New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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