I\'m using the following query to get the next month.
int theMonth = ((System.DateTime)periodStartDate).Month+1;
But if the periodstartDate
The expression ((System.DateTime)periodStartDate).Month+1 doesn't throw an error if the month is December - it just returns 13. I suspect you're doing this:
var nextMonth = new DateTime(periodStartDate.Year, periodStartDate.Month + 1, 1);
That would throw an error.
Try this instead:
var nextMonth = new DateTime(periodStartDate.Year, periodStartDate.Month, 1)
.AddMonths(1);