I hate dates. So I'm maintaining a project and came across an extension method which is a bit naive, but should do the trick in 99% of cases. It is checking a date range:
public static bool IsInRange(this DateTime dateToCheck, DateTime startDate, DateTime endDate)
if (startDate <= endDate)
return dateToCheck >= startDate && dateToCheck <= endDate;
If you check your
dateToCheck variable closely, the year is 1917 which is obviously smaller than 2017(
enddate year is 2017). So, it's working as expected as far as I can see.