Search code examples
asp.net-mvcdate-format

MVC SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM


I am currently working on a new project with an existing database. When I try to load my program, the error above happens. When I checked the existing database, I found the birthday in format yyyy/mm/dd(e.g. 1951-03-13 00:00:00.000 ).

I tried to modify the model to

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateTime? birthday{ get; set; }

but the error kept on showing. I tried doing other stuff in but still showing error. Thanks in advance.

UPDATE STACK TRACE


Solution

  • UPDATE

    Ok now I found what was causing the error, it was due to a row with a value of <Unable to retrieve the data>. The problem triggered the error I am experiencing. To solve this, I simply updated the row using a SQL update command.