Reputation: 209
Whenever i try to update an object that has a registered date field, this value is being passed in the model
{01/01/0001 00:00:00}
It happens even when i add
<%: Html.EditorFor(model => model.RegisteredDate) %>
into the view, even though the registered date is displayed in the editor like
18/03/2011 00:00:00
The other value is being passed and throwing the following error
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Has anyone else experienced anything like this?
Upvotes: 3
Views: 3125
Reputation: 1381
The date you gave - 18/03/2011 - looks to be in the format day/month/year, which is invalid. The default format for DateTime is month/day/year (MM/dd/yyyy). .Net is trying to parse 18 as a month, which obviously is wrong, hence the error and the default datetime value of 01/01/0001 00:00:00 being used.
Upvotes: 4