I tried to calculate Diff by doing computed column > Advanced expression and then `datetime() - t1.datetime / 60 `. Diff is actually the difference between SAS_update and DateTime, SAS_Update is just the lastruntime (datetime())
This is what I got:
I get a very weird value but I expected Diff to have value -1 because there is a a difference of -1 minutes between them SAS_update and DateTime...
Use the function intck.
Datetime-variables are, without a format, the number of seconds passed from 1Jan1960 to the actual datetime. The function takes care of the details, if you need the difference in minutes, then use "dtminute" as interval.
@Andalusia wrote:
Could you show an example?
Looks like this:
intck('minute',t1.datetime,datetime(),"c")
The "c" (for continuous) means that difference / 60 is used, and not the count of minute boundaries between the two values (90 seconds difference can turn out to be 2 minutes if the default is used).
For reference, run this:
data _null_;
time = datetime();
rc = sleep (119,1);
diff1 = intck('minute',time,datetime(),"c");
diff2 = intck('minute',time,datetime());
put _all_;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.