If given a date and a variable n, how can I calculate the DateTime for which the day of the month will be the nth Date?
For example, Today is the 17th of June. I wou
Why not just do?
private DateTime GetNextDate(DateTime dt, int DesiredDay) { if (DesiredDay >= 1 && DesiredDay <= 31) { do { dt = dt.AddDays(1); } while (dt.Day != DesiredDay); return dt.Date; } else { throw new ArgumentOutOfRangeException(); } }