title: Advice on displaying nullable datetime C#/MVC
body: <p>I have a nullable datetime hat I get from the DB. currently I have my datetime? properties in my model and call them like this in the view to work properly.</p>
  
  <pre><code>&lt;h6&gt;@GTSConnectContent.DateOfLoading: &lt;span&gt;
      @{
          if (@consignmentDetails.DateOfLoading.HasValue)
          { 
          @consignmentDetails.DateOfLoading.Value.ToShortDateString();
          }
      }
  &lt;/span&gt;
  &lt;/h6&gt;
  </code></pre>
  
  <p>But isn't there a way to set it in the actual model so it doesn't have to be set like this in the view. I tried the following but doesn't work</p>
  
  <pre><code>[DisplayFormat(DataFormatString = "yyyy/MM/dd")]
      public DateTime? DateOfLoading { get; set; }
  </code></pre>