In your MVC models, if you have a date property which is populated from the database with Date and Time, it’s very easy to format the output so that it’s just the date (toShortString()). However, there are two ways to do this, using Display/Edit Annotations.

The first way is more difficult than the other because you will need to remember the ASP.Net format string. If you already have this memorized, of course, it’s not that big of a deal – {0:d}. This is and can be used in many places in regular Web Forms development. To use it, you would type this above your property:


[DisplayFormat(DataFormatString=”{0:d}”]

The other, easier way is use the DataType attribute of the Display Annotations:


[DataType(DataType.Date)]