Thanks everyone for your help. Here is the latest version. Instead of an array, I just check ranges.
code:
FUNCTION WorkDaysDiff($sStrtDte, $sEndDte)
; $sStrtDte and $sEndDte are date strings in the form YYYY/MM/DD
; Function returns the integer number of work days between the two
; dates.
; Dependencies: Flip_SerDate() or SerialDate()
; Note: If a serial date function is added to KiXtart, the iEndDOW
; calculation may need to be adjusted to get the correct DOW.
DIM $iDaysDiff, $iEndDte, $iWeeks, $iEndDOW, $iCtr
$iEndDte=Flip_SerDate($sEndDte)
$iDaysDiff=$iEndDte-Flip_SerDate($sStrtDte)
$iWeeks=$iDaysDiff/7 ; Remove full weeks, since each contains 5 work days
$iDaysDiff=$iDaysDiff-(($iDaysDiff/7)*7) ; $iDaysDiff mod 7 = remainder of days
$iEndDOW=($iEndDte-(($iEndDte/7)*7))+1 ; Returns correct DOW for the end date
$iStrtDOW=$iEndDOW-$iDaysDiff
IF $iStrtDOW < 0 $iStrtDOW=$iStrtDOW+7 $iEndDOW=$iEndDOW+7 ENDIF
FOR $iCtr = $iStrtDOW TO $iEndDOW-1 ; Eliminate last day from count
IF (($iCtr>1) AND ($iCtr<7)) OR (($iCtr>8) AND ($iCtr<12))
$WorkDaysDiff=$WorkDaysDiff+1
ENDIF
NEXT
$WorkDaysDiff=$WorkDaysDiff+($iWeeks*5)
ENDFUNCTION
New Mexico Mark