you have startMonth sometimes a number and sometimes a string.  That's going to cause problems.  Don't add the leading 0 until you need to convert to a string.