title: How to convert to yyyy-MM-dd format for DateTime?
body: <p>I have a MVC action method which accept 2 date parameters. I tried to use <code>.ToString</code> but it gives me this error:</p>
  
  <blockquote>
    <p>Returns the text representation of the value of the current
    Nullable object.</p>
    
    <p>No overload for method 'ToString' takes 1 arguments.</p>
  </blockquote>
  
  <p>I need to convert it to <code>yyyy-MM-dd</code> before pass it to the view. Otherwise, the textbox won't able to show the date value. Here is the code</p>
  
  <pre><code>public ActionResult Index(DateTime? dateFrom, DateTime? dateTo)
  {            
      ViewBag.DateFrom = dateFrom.ToString("yyyy-MM-dd");
  
      return View();
  }
  </code></pre>