Using a combination of date functions you can calculate the number of days in a given month.
Basically, you get the first day of the month, add a month to get the first day of the next month, and then get the number of days between them, which will give you the number of days in the month of the specified date ("the date").
The rules are as follows:
the number of days in the month = DayDifference(the start of the month, the start of the next month)
the start of the month =MakeDate(the year, the month, 1)
the start of the next month = AddMonths(the start of the month, 1)
the year = ExtractYear(the date)
the month = ExtractMonth(the date)