How to generate report per month with an start and end date only?

How to generate report per month with an start and end date only?

Hello, i have a problem on understanding the best way to achieve something that i think could be simple:


My students have an enrollment start and end date that can span up to six years. I want to show one year the months and the number of students on each month. I can't use the start date only because it will show count the student only in one month, same with the end date.

I want to generate a chart like the one that follows. Now, this chart is working but in a horrible way.

Once a record is made I generate a record per  each month in between the Start and end date. In the worst cases it will be 12 months * 6, 72 records for one single Student. If my mother was a programmer I think you will tell me to not to do this, is quite dirty in my opinion. 

So I am looking for a better way to do this, anyone?

I have thought about making a record per month with the three students categories and then just add up the numbers but i will lose the ability of seeing the underlying data like name and so on. 

I hope someone can help or point me in the right direction, I have been with my head on this for some days now.

Thanks