🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 10-17-2018 02:53 AM
(60672 views)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data _null_;
x = today();
format x ddmmyy10.;
y = datetime();
format y datetime20.;
put "Formatted day: " x " , formatted datetime: " y;
run;
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data _null_;
x = today();
format x ddmmyy10.;
y = datetime();
format y datetime20.;
put "Formatted day: " x " , formatted datetime: " y;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can multiply the date you get from today() by 86400 to get DD:MM:YYYY:00:00:00