The DateTime
data type in .NET exposes some properties, such as .Date
(the same date value, but with time set to 12am), .TimeOfDay
, .Year
, etc. The example blog post you're referring to uses DateTime
, thus all of these properties are available. Also note that DateTime
is a value type and cannot be null
.
Your model, on the other hand, uses a property of type DateTime?
which is a reference type and can be null
. Nullable types are reference type wrappers around value types. All of them expose a property called .HasValue
of type bool
, and a property .Value
of the type that the wrapping nullable type corresponds to. In case of DateTime?
, the type of the .Value
property is DateTime
.
With your model the following should work:
<%: Html.EditorFor(model => model.Start.Value.Date)%>