|
This is sample code. Add error handling and adjust to your requirements as necessary. |
FUNCTION NthDowOfMonth(tnYear, tnMonth, tnOccurrence, tcDow)
* Parameters
* tnYear, tnMonth - Year and Month
* tnOccurrence - Day of week occurrence (1-5)
* tcDow - Day of week name (at least 3 first characters)
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 + (tnOccurrence -1)*7)
CATCH
ldDate = {}
ENDTRY
ENDIF
RETURN ldDate
Recent comments
1 week 5 days ago
1 week 5 days ago
2 weeks 2 hours ago
2 weeks 1 day ago
2 weeks 2 days ago
2 weeks 5 days ago
3 weeks 5 days ago
3 weeks 6 days ago
4 weeks 14 hours ago
4 weeks 4 days ago