Based on two dates received per parameter, I am trying to list all the dates per month (one date per month) based on the start date and until the end date. These returned dates must check which day of the week of the start date and the number of the week to replicate that date for every month.
For example, @StartDate = 2016/04/15
and @EndDate = 2016/09/01
, I find that the @StartDate
is on a first Friday in April, so up to @EndDate
would date for every first Friday of every month:
2016/05/06
2016/06/03
2016/07/01
2016/08/05
For @StartDate = 2016/04/12
and @EndDate = 2016/09/01
, check that @StartDate
is on the second Tuesday of April, then fetch every second Tuesday of each month:
2016/05/10
2016/06/14
2016/07/12
2016/08/09
In the case of @StartDate = 2016/04/28
and @EndDate = 2016/09/01
, I find that @StartDate
is in the last week to Thursday of April:
2016/05/26
2016/06/30
2016/07/28
2016/08/25
In this last case, you would have to take into account the number of weeks of each month, since there are months with 4 and another with 5 weeks.