SQL Statement below is for MySql Database to get the total day of month.
SELECT DAY(LAST_DAY(now()))
Example of SQL Statement to get the total day of month.
SELECT DAY(LAST_DAY('2007-06-05 22:40:51'))
Return Value = 30
I tested MySql Server 5.0, it is work.