The Case of the Different Dates

I ran into an issue in an MVC application where I had two dates in a table. One was being displayed as just a date, and the other included the time component as well. I just wanted the date. The difference was that the property in the model for the time-less date had a DataType attribute and the other date didn’t:


       [DisplayName("Enter Date")]
       public DateTime EnterDate { get; set; }


       [DisplayName("Work Date")]
       public DateTime WorkDate { get; set; }

Adding the attribute fixed the issue.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: