The following formula counts the number of weekdays (but not weekend days):
diffDays := (EndDate - StartDate) / 86400 + 1; strtDay := @Modulo(@Weekday(StartDate); 7); endDay := @Modulo(@Weekday(EndDate); 7); result := (diffDays - endDay + strtDay - 8) * 5 / 7 - @Max(-2; -strtDay) - @Min(1; endDay) + 5 - strtDay + endDay