>FUNCTION NthDowOfMonth(tnYear, tnMonth, tnWeekNum, tcDow) >LOCAL lnDOW, ldDate, lnDowPos >lnDowPos = AT(UPPER(PADR(tcDow,3)), "SAT SUN MON TUE WED THU FRI") >IF lnDowPos = 0 > ldDate = {} >ELSE > TRY > lnDOW = DOW(DATE(tnYear, tnMonth, 01), INT(lnDowPos/4) + 1) > ldDate = DATE(tnYear, tnMonth, 7 - lnDOW + 1 + (tnWeekNum -1)*7) > CATCH > ldDate = {} > ENDTRY >ENDIF >RETURN ldDate >>>I dared to expand it to make it more generic