Hi,
I am doing below for today's time and date.
%let dt1= %sysfunc(putn(%eval(%sysfunc(today())-1),datetime.));
%put &dt1;
This is showing below date - 01JAN60:06:13:04
How can i get current TIME that also with leading zero in case it is single digit.
Thanks
Use format date. instead of datetime.
Thanks for replying. What about the Time part of it . I would need time part with leading zero if its single digit
%let dt1= %sysfunc(putn(%eval(%sysfunc(today())-1),datetime.));
There is no time associated with today()
Or, trivially, the time associated with today() is 00:00:00.
So what do you want from today()?
Dates are counts of days, while times and datetimes are counts of seconds. With 1960-01-01T00:00:00 as the zero point, today's date value (22385) will show up as a datetime sometime on 1960-01-01.
How you format the value (or not) depends on the further use. If you do not need it for display, the raw value is best, as you can then use the macro variable without further ado:
%let dt1=%sysevalf(%sysfunc(datetime())-86400);
%put &=dt1.;
data want;
set have;
if datetimevalue le &dt1.;
run;
With DATETIME(), you will get time down to microseconds, so you need to use %SYSEVALF to cope with the fraction.
TODAY() is just an alias for DATE() which returns a date value (number of days) not a datetime value (number of seconds).
To get the current datetime value use DATETIME() function instead of DATE() function. To have the string formatted properly use at least a width of 19 in the format specification, otherwise you will get only two digits for the year.
%let dt1= %sysfunc(intnx(dtday,%sysfunc(datetime()),-1,s),datetime19.);
To get the current time of day (seconds since midnight) use the TIME() function. To format it with leading zeros use the TOD format.
Want to review SAS CI360? G2 is offering a gift card or charitable donation to One Tree Planted for each accepted review. Use this link to opt out of receiving anything of value for your review.
SAS Customer Intelligence 360
Training Resources
SAS' Peter Ansbacher shows you how to use the dashboard in SAS Customer Intelligence 360 for better results.
Find more tutorials on the SAS Users YouTube channel.
Want to review SAS CI360? G2 is offering a gift card or charitable donation to One Tree Planted for each accepted review. Use this link to opt out of receiving anything of value for your review.
SAS Customer Intelligence 360
Training Resources