I get the following error in a page where I use a datepicker. No matter what day is inserted, this error happens: 14-Fev-1991. What is that? Today is 14-Fev but not 1991! What should I do? Did anything change in the server? This used to work, but now it doesn't! Help... String was not recognized as a valid DateTime. [FormatException: String was not recognized as a valid DateTime.] System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +3211050 System.DateTime.Parse(String s, IFormatProvider provider) +28 System.ComponentModel.DateTimeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +290 [FormatException: 14-02-1991 is not a valid value for DateTime.] System.ComponentModel.DateTimeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +452 System.ComponentModel.DataAnnotations.RangeAttribute.SetupConversion() +626 System.ComponentModel.DataAnnotations.RangeAttribute.IsValid(Object value) +38
This is a coding error. How did you design your database? Check your database and see if it is storing any dates. It maybe that it is storing a data with 1991 on it.
Questions towards a solution I am storing 2 date and time values in 2 fields with the corresponding SQL Server types, but the dates I inserted (too many) have absolutely nothing to do with the "Today" day and the year 1991. My code works perfectly locally (connecting to the Winhost SQL database), but not in the server. So, at this point, I know the problem cannot be in the database itself. But where can Winhost help me? * Is there a way to debug the code running at Winhost? * Could it be that any culture difference may be ruining everything? * What would be the best path to follow when something so extraordinary happens? By the way, why is 14-02-1991 considered an invalid date? What culture considers 14 to be the month? This is the only problem that is stopping this project to be delivered. Please take a moment to give me the hints I need. Thanks, Fabio Milheiro
14-02-1991 shouldn't be an invalid date format. Do you have a way for us to replicate this problem on our end?
Code error The error was due to the fact that I was trying to convert the data 20 years from now from a string from a not standard format. I solved the problem by convert the 20 years ago date to a string standard format (.ToString("s") I am glad the problem was not on the server. Thanks!