Quartz | Level 8

## intck('days') vs intck('weekdays')

DATA EXAMPLE;

START = '05APR2014:09:00:00'DT;

END    = '08APR2014:10:25:16'DT;

DAYS           = INTCK('DAYS',           DATEPART(START), DATEPART(END);

WEEKDAYS = INTCK('WEEKDAYS', DATEPART(START), DATEPART(END);

RUN;

Why does it return DAYS = 3?

I was expecting DAYS = 4, and WEEKDAYS = 2.

3 REPLIES 3
Quartz | Level 8

## Re: intck('days') vs intck('weekdays')

I will be reading the manual, but some explanation from the community will help.

I mean whatever is the behaviour, I was expecting it should apply to both DAYS and WEEKDAYS.

It screwed my logic: Turnaound Time In Hours = INTCK(HOURS) - 24 * (INTCK(DAYS) - INTCK(WEEKDAYS))

Opal | Level 21

## Re: intck('days') vs intck('weekdays')

intck is counting the number of boundaries crossed.  From Apr 5, one has to cross six, then seven, then eight to arrive at eight, i.e., 3 days.

For weekdays, it is the same thing.  From Apr 5, the first weekday crossed is the 7th, then the 8th, or 2.

Opal | Level 21

## Re: intck('days') vs intck('weekdays')

As for you calculation of hours, IF you are assuming 24 valid hours in each workday, and that start and end will ALWAYS be workdays, then you could use something like:

DATA EXAMPLE;

START = '05APR2014:09:00:00'DT;

END    = '08APR2014:10:25:16'DT;

DAYS= INTCK('DAYS', DATEPART(START), DATEPART(END));

WEEKDAYS = INTCK('WEEKDAYS', DATEPART(START), DATEPART(END));

if days lt 1 then Turnaound_Time_In_Hours=(timepart(end)-

timepart(start)/(60*60));

else do;

Turnaound_Time_In_Hours=(24*60*60-timepart(start)+(weekdays-1)*

(24*60*60)+timepart(end))/(60*60);

end;

RUN;

That will produce a calculation of 49.42 hours for your example.

Discussion stats
• 3 replies
• 2604 views
• 1 like
• 2 in conversation