BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
YannRC
Obsidian | Level 7

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

 

YannRC_0-1767783667300.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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

 

View solution in original post

3 REPLIES 3
FreelanceReinh
Jade | Level 19

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

 

YannRC
Obsidian | Level 7

Perfect !!

Thank you very much

Tom
Super User Tom
Super User

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;

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 184 views
  • 2 likes
  • 3 in conversation