Given two dates like 20120302 and 20120605
I need to get a list of Months and the total days in those months that fall between those two dates, like so:
March 28
April 30
May 31
June 03
|
Given two dates like I need to get a list of Months and the total days in those months that fall between those two dates, like so:
|
|||||||||
|
|
Here's my attempt. Still think there are unanswered questions in your sample data, though.
Results:
|
||||
|
|
|
You can use a recursive CTE to build a list of dates and group by month. This will not give you the exact output you need but it should give you an idea of what you can do.
Result:
|
|||
|
|
|
This should work too.
--njds |
|||
|
|
|
Because I enjoy these types of questions, I will throw a solution I use often into the mix.
|
|||
|
|