LPARAMETERS dDate1, dDate2 LOCAL wks, wkd hd = MAX(ddate1,ddate2) ld = Min(ddate1,ddate2) wks = INT( (hd - ld)/ 7) * Return Weeks * 5 which is overal workdays * Adjust for starting day of the first week * And adjust for the last partial week RETURN ; INT(wks * 5 + ; IIF(DOW(ld,2) < 6, 6-DOW(ld,2),0) + ; IIF(DOW(hd,2) < 6, DOW(hd,2),0) )>You must not have copied my code from this page because with this code I get 4, not 11. I admit 4 is incorrect but I am still debugging. I will post an improved version in a few minutes.
>>>LPARAMETERS dDate1, dDate2 >>>LOCAL wks, wkd >>> >>>hd = MAX(ddate1,ddate2) >>>ld = Min(ddate1,ddate2) >>> >>>wks = INT( (hd - ld)/ 7) >>> >>>* Return Weeks * 5 which is overal workdays >>>* Adjust for starting day of the first week >>>* And adjust for the last partial week >>> >>>RETURN ; >>> INT(wks * 5 + ; >>> IIF(DOW(ld,2) < 6, 6-DOW(ld,2),0) + ; >>> IIF(DOW(hd,2) < 6, DOW(hd,2),0) ) >>> >>>>>>
>>>ld = RAND(-1) >>>nStart = SECONDS() >>>FOR i = 1 TO 100000 >>> noffset = INT(RAND()* 36) >>> ld = GOMONTH(DATE(),1-noffset) >>> hd = GOMONTH(DATE(),noffset) >>> wkd = workdays(ld,hd) >>>ENDFOR >>>MESSAGEBOX('Execution time was '+TRANSFORM(SECONDS()-nstart)+' seconds') >>>>>>