My requirement was to write a code that can accept two type of date format i.e yyyymmddhhmmss and yyyymmdd. I have written the code but it is working for few date but not for all.
string[] formats = { "yyyymmdd","yyyymmddhhmmss" };
if (!DateTime.TryParseExact(DesiredReportVersionDate, formats, new CultureInfo("en-US"), DateTimeStyles.None, out timevalue))
{
valid = false;
throw new Exception("invalid format" + timevalue);
}
However,passing 19901212033047 value is giving exception.It should be valid as per my understanding.
Please help.
Thanks in advance