Period from Dates

Hello all developers.

I have a requirement to be achieved.

I have two dates for example start date and end date. i want to create month wise periods based on start and end date

Lets say for example

Start date = 6/8/2010

End date = 5/2/2012

Hence i should get the result as follows

Period = 6/8/2010 - 31/8/2010

Period = 1/9/2010 - 30/9/2010

Period = 1/10/2010 - 31/10/2010

:

:

:

:

Period = 1/1/2012 - 31/1/2012

Period = 1/2/2012 - 5/2/2012

Please help me out of this dilemma…

All what you need is endMth().

The first period is <StartDate, endMth(StartDate)>. The next period is <x, endMth(x)>, where x = endMth(StartDate)+1. And so on.