System.FormatException' in mscorlib.dll code example
Example: Exception thrown: 'System.FormatException' in mscorlib.dll dates
/* Just putting this here for myself, but maybe it will help someone else too:
If this error occurs when you are importing data from Excel,
it is possible that your computer's regional settings are incorrect.
Try using ExactParse if in C# , and if there are still issues it may be the
Excel/ regional setting combo causing the issue.
*/
try
{
formattedDate = DateTime.ParseExact(dateString, "dd/MM/yyyy", null).ToString("yyyy-MM-dd");
}
catch
{
// Might be the wrong expected format, might be regional settings
}