MSSQL store DateTime format is standard. But sometimes we need change the format to display it to user, let them more easy read and understand which Datetime format was set in our Application.
If use ASP.net retrieve the MSSQL DateTime Data to you application, it will display like below format.
But, when validate the DateTime with ASP.net it will return an error.
Because the DateTime format set in ASP.net was “06-03-2014 12:00:00 AM”. But now we just need to display Date only not need time.
To let it display properly on our application. We can set the DateTime format on our Model file. Open the Model file, and then set it like below example:
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")] public DateTime CreateDate { get; set; }
Refresh the page, you will found that the DateTime field already change the format as you set. And you not need change “March” to “03” to pass the validate.