My function is....
FUNCTION EndMonth
LPARAMETERS tnMonth, tnYear
IF PCOUNT()<1
tnMonth = MONTH(DATE())
ENDIF
IF PCOUNT()<2
tnYear = YEAR(DATE())
ENDIF
IF m.tnMonth=12
RETURN DATE( m.tnYear, 12, 31)
ELSE
RETURN DATE( m.tnYear, m.tnMonth+1, 1) - 1
ENDIF
ENDFUNC