Subtract one month from Datetime.Today
Patrick got it. To build on his answer and improve error handling (if there's a possibility that qs
could be an invalid date string), you might do something like:
DateTime qsValue;
dateTimePicker1.MaxDate = DateTime.Today.AddMonths(-1);
dateTimePicker1.Value = (DateTime.TryParse(qs, out qsValue))
? qsValue
: dateTimePicker1.MaxDate;
Just substract a month by 'adding` -1:
var lastmonth = DateTime.Today.AddMonths(-1);
See the MSDN documentation on DateTime.AddMonths
.