>* Call passing the day number of week to test for and current date >* Returns: 1 after date >* 2 before date >* 3 equals date >* 0 indeterminate (error) > >FUNCTION LastDaySelect >LPARAMETERS pnLastDay,pdCurDate >LOCAL ldLastDayofMonth, lnLastDay, lnDate >ldLastDayofMonth = GOMONTH(DATE(YEAR(pdCurDate),MONTH(pdCurDate),1),1) - 1 >lnLastDay = DOW(ldLastDayofMonth) >IF (lnLastDay - pnLastDay) > 0 > ldTestDayofMonth = ldLastDayofMonth - (lnLastDay - pnLastDay) >ELSE > ldTestDayofMonth = ldLastDayofMonth - (pnLastDay + lnLastDay) + 1 >ENDIF >DO CASE > CASE ldTestDayofMonth < pdCurDate > lnDate = 1 > CASE ldTestDayofMonth > pdCurDate > lnDate = 2 > CASE ldTestDayofMonth = pdCurDate > lnDate = 3 > OTHERWISE > lnDate = 0 >ENDCASE >RETURN lnDate >ENDFUNC >