Wednesday, February 28, 2007

DateTime.Parse

DateTime.Parse() function in the .net behaves depending on the system settings.
If the date format set in the system is dd/mm/yyyy and you try to parse the date which of "mm/dd/yyyy" format it will throw an error "String was not recognized as a valid date time".

To overcome this,
Regional and Language Settings --> Regional options-->
Customize-->Date-->Short date format.

change the format in this Short date format dropdown which solves the problem.