I have two text-boxes which are used to select a From and a To date. I need to have a loop where the outer loop will be for a year and the inner loop will run for each month.
Problem is with the code below, if I choose 11/01/2011 and 06/30/2012, my month loop runs once for month 11. After that the loop exits.. Any help is appreciated.
I’m using the code below to look into a SharePoint Calendar List (using CAML query) and fetch number of times 3, 5 consecutive days a certain room is available excluding week ends. Idea is to use CAML query to get the number of free days for each month and keep repeating till the last selected month.
int year = 0, month = 0;
for (year = Calendar1.SelectedDate.Year; year <= Calendar2.SelectedDate.Year; year++)
{
int i = year;
for (month = Calendar1.SelectedDate.Month; month <= Calendar2.SelectedDate.Month; month++)
{
int j = month;
}
}
If I understand you correctly you want to iterate through each month between the 2 dates. If so, this should work: