I am working on a project where I am reading in a file which could come in two different formats, one includes a date and time and the other doesn\'t.
When I read i
This worked for us:
If the string value is a valid datetime value, then it will not give any exception:
try { Convert.ToDateTime(string_value).ToString("MM/dd/yyyy"); }
If the string value is an invalid datetime value, then it will give exception:
catch (Exception) { }