count the Days of a month

WolfStone

New Member
Hi

Can anybody help me?

I would like to write a function, that returns the number of days of a month.
The INPUT PARAMETER should be a Month and a year.

How could I do that??

Please help... :confused:

Regards

WolfStone
 
3 Solutions:

1) Hardcode it - "30 Days has September, April, June, and November...."
2) Make a date variable set to the first day of the month in the particular year and then add 1 day to it until the month changes, noting when it does
3) Set the date variable to the next month and minus a day, and then grab the day.
 
Code:
function month_days returns int (iDate as date):
	/*
	 * Start at 28 as no month has < 28 days
	 */
	iDate = date(month(iDate), 28, year(iDate)).
	repeat:
		if month(iDate) <> month(iDate + 1) then leave.
		iDate = iDate + 1.
	end.
	return day(iDate).
end function.
 
Back
Top