0

can I somehow use a substring for this:

@Html.DisplayNameFor(model => model.Birthday)

Currently it displays 06/27/2000 and I want it to display 06/27.

Andrei
  • 55,890
  • 9
  • 87
  • 108
EbertB
  • 95
  • 3
  • 9
  • 1
    Did you actually mean `DisplayFor`? `DisplayNameFor` displays the name of the property, it would output "Birthday" – Andrei Jun 27 '19 at 14:32
  • 1
    Possible duplicate of [How to render a DateTime in a specific format in ASP.NET MVC 3?](https://stackoverflow.com/questions/6001654/how-to-render-a-datetime-in-a-specific-format-in-asp-net-mvc-3) – Andrei Jun 27 '19 at 14:33
  • Have a look at `DisplayFormat` annotation https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.displayformatattribute.dataformatstring?view=netframework-4.8 – schlonzo Jun 27 '19 at 14:34
  • Yes Sorry DisplayFor @schlonzo I tried to use the information in that link but I do not see how to strip out the year. – EbertB Jun 27 '19 at 14:39
  • @schlonzo OK I figured it out with that link! Thank! – EbertB Jun 27 '19 at 14:47

0 Answers0