Hello, I’m trying to measure a time interval between two dates in business days. I know I’m supposed to use the INTCK function, but I don’t understand what it is actually calculating. It gives me a result of 1700, which doesn’t make sense.
It's the difference between DATE_DER_EVT and today. I have used this synthax :
INTCK('WEEKDAY',DATEPART(TODAY()),DATEPART(t1.DATE_DER_EVT))
If you can help me
Hello @YannRC,
You must not apply the DATEPART function to date values (like TODAY()), only to datetime values such as DATE_DER_EVT. Otherwise, a number of days since 1 Jan 1960 (TODAY()=24113 on 7 Jan 2026) is interpreted as a number of seconds since 1 Jan 1960 00:00:00 (24113 seconds = 6:41:53 h) and the datepart of the resulting datetime value equals '01JAN1960'd (=0). This is why you got the number of weekdays from 1 Jan 1960 to DATE_DER_EVT:
INTCK('WEEKDAY','01JAN1960'd,'07JAN2026'd)=17223
Hello @YannRC,
You must not apply the DATEPART function to date values (like TODAY()), only to datetime values such as DATE_DER_EVT. Otherwise, a number of days since 1 Jan 1960 (TODAY()=24113 on 7 Jan 2026) is interpreted as a number of seconds since 1 Jan 1960 00:00:00 (24113 seconds = 6:41:53 h) and the datepart of the resulting datetime value equals '01JAN1960'd (=0). This is why you got the number of weekdays from 1 Jan 1960 to DATE_DER_EVT:
INTCK('WEEKDAY','01JAN1960'd,'07JAN2026'd)=17223
Perfect !!
Thank you very much
You asked to calculate the number of week days since the start of 1960 of instead today's date. Dividing a date value by the number of seconds in a day almost always results in a value of zero.
INTCK('WEEKDAY',TODAY(),DATEPART(t1.DATE_DER_EVT))
But the easiest fix is to use the DTWEEKDAY interval instead so you can work with the existing datetime values. Make sure to pass a valid datetime value as the reference value.
INTCK('DTWEEKDAY',DATETIME(),t1.DATE_DER_EVT)
Try this example:
data have;
do days=1 to 20 ;
timestamp=intnx('dtweekday',datetime(),-days,'s');
output;
end;
format timestamp datetime19.;
run;
data want;
set have;
edays = intck('dtweekday',timestamp,datetime());
run;
proc print;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.