Error1: String was not recognized as a valid DateTime
Error2: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
How to fix it?
- Set culture in web.config
In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page.
Solution
add a
globalization section to the Web.config file, and then set the
uiculture and
culture attributes, as shown in the following example:
<
globalization
uiCulture
=
"es"
culture
=
"es-MX"
/>
And for more detail about coding, you can refer to:
Article ID: 1461, Created: July 30, 2013 at 1:49 AM, Modified: February 26, 2021 at 12:49 AM