Answers for "Exception thrown: 'System.FormatException' in mscorlib.dll dates"

C#
0

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
}
Posted by: Guest on May-22-2020

Code answers related to "Exception thrown: 'System.FormatException' in mscorlib.dll dates"

C# Answers by Framework

Browse Popular Code Answers by Language