[Solved] How to get an exact 6 month date range?


Moving juharr’s comment as an answer, as it is correct

Simply change:

DateTime startDate = endDate.AddMonths(-6);

to

DateTime startDate = new DateTime(date.Year, date.Month, 1).AddMonths(-5);

solved How to get an exact 6 month date range?