I am working on getting the date validated before we insert them in to the mySQl server. Below is what I am trying
DateTime startDate = new DateTime(2009, 12, 31);
var currentTime = DateTime.Now;
DateTime endDate = currentTime.Date;
DateTime DOB = DateTime.ParseExact(emp[i].DateOfBirth, "yyyy-MM-dd HH:mm:ss,fff", System.Globalization.CultureInfo.InvariantCulture);
if (!(DOB.Date > startDate && DOB.Date <= endDate))
{
WriteValidationFailure("Failed - DOB is Invalid");
}
Here emp[i].DateOfBirth
is a string and hold the value like 01/01/2009
. When I run the application it throws