What is the cleanest way to check if a supplied date is in a given date range? For example:
DateTime? maxDate
DateTime? minDate
DateTime? userDate
I want to check if the userDate is in the range. Where min or max can be null.
So for example:
minDate = new DateTime(2017, 1, 1);
maxDate = null;
userDate = new DateTime(2017, 5, 3);
In this scenario userDate would be in the range since it's greater then the minDate and no maxDate was specified.
I thought about using DateTime.Compare but it seems that I would create a mess of if/then statements to check userDate to the minDate and maxDate variables since the DateTime.Compare will only compare 2 dates at a time.