I have a web page that gets data from a text file. In a certain position, sometimes there is a date and sometimes not. I need to check if this position contains a valid date or not. Here is some code I wrote to check:
DateTime admitDate;
if (DateTime.TryParse(StrAdmitDateTime, out admitDate))
{
// Valid Date
}
else
{
admitDate = GetAdmissionDate(objPatient.strAccountNumber);
}
StrAdmitDateTime has a value of 201406161052. When I run the above code using this date, it goes to the else. How can I change the above code to work for dates in this format?
Go to the complete details ...