The easy way is to work out the last day of the month.
numbervar m:= month({table.date}) + 1;
numbervar y:= year({table.date});
datevar lastday;
//Check it's not January in the following year
if m > 12 then (y := y + 1; m := 1);
//Last day of month is...
lastday := Date(y,m,1) -1;
//Days in month is equal to
day(lastday)