1

I have this code:

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString =  "{0:dd/mm/yyyy}")]
public DateTime EstimatedResolveDate { get; set; }

Its in ViewModel. When the ViewModel is displayed on the page, I would like for the time portion to be hidden. Problem is the code doesn't do this and Im not sure why?

9
  • Are you using @Html.DisplayFor(x => x.EstimatedResolveDate) in your view? Commented Apr 10, 2014 at 23:01
  • 2
    possible duplicate of ASP.Net MVC DisplayFormat Commented Apr 10, 2014 at 23:03
  • 2
    Here is a fiddle showing how to use DisplayFor: dotnetfiddle.net/8VWHpL Commented Apr 10, 2014 at 23:06
  • 4
    And also change this "{0:dd/mm/yyyy}" to "{0:dd/MM/yyyy}" Commented Apr 10, 2014 at 23:07
  • 1
    like this: @Html.DisplayFor(m => item.EstimatedResolveDate) or @Html.DisplayFor(m => (DateTime)ViewBag.EstimatedResolveDate) Commented Apr 11, 2014 at 0:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.