Reebo,
The formula you provided has one minor flaw. It does not count the first day if it falls on a weekday. (see this thread thread149-304415)
A check for the the DOW of the first date in the range can be added to add that day to the total.
numbervar days ;
days:=
DateDiff ("d", {StartDateField}, {EndDateField}) -
DateDiff ("ww", {StartDateField},EndDateField},crSaturday) -
DateDiff ("ww", {StartDateField}, {EndDateField}, crSunday)
if dayofweek(StartDateField) in [2,3,4,5,6] then days:=days+1;
days
If you have CR8 or above, here is a loop I created to count days.
datevar firstday:={StartDateField});
datevar lastday:={EndDateField};
numbervar loop;
local numbervar wds;
numbervar span;
span:=lastday-firstday;
For loop:= 0 to span do(
if dayofweek(firstday+loop)in [2 to 6] then wds:=wds+1 else wds:=wds);
wds
Mike