I suggest to split this problem into two steps:
1. Create a calendar
2. Count days and months based on the load statement, like this:
COUNT(DATE) AS DAYS,
COUNT(DISTINCT MONTH) AS MONTHS
(DATE >= '$(dateStart)') AND
(DATE <= '$(dateEnd)')
"dateStart","dateEnd" - variables.
This will give you exactly what you need.