{01/01/0001 00:00:00} passed as the default date and time, MVC 2

Whenever I try to update an object with a registered date field, this value is passed in the model

  {01/01/0001 00:00:00}

This happens even when I add

  <%: Html.EditorFor(model => model.RegisteredDate) %>

to the view, even if the registered date is displayed in the editor, for example

 18/03/2011 00:00:00

Another value is transmitted and produces 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 something like this?

+3
source share
1 answer

The date you specify - 03/18/2011 - looks in the format day / month / year, which is invalid. The default format for DateTime is month / day / year (MM / dd / yyyy) .. Net tries to parse 18 as a month, which is obviously incorrect, so the error is used and the default value for date and time is 01/01/0001 00 : 00: 00.

+2
source

All Articles