title: Web date picker: Getting @html helper in MVC to set input type as 'date' rather than 'datetime'
body: <p>I am writing an MVC application in ASP.NET and dutifully using the @html helpers to produce form elements. However, I cannot find a way to get the helper to set the <code>type</code> attribute on the <code>input</code> element to <code>date</code> (which gives me a convenient date picker) rather than than <code>datetime</code> (reflecting the C# data type).</p>
  <p>The helper code is:</p>
  <pre><code>@Html.EditorFor(model =&gt; model.StartDate, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
  </code></pre>
  <p>(<code>StartDate</code> has type <code>DateTime</code>)</p>
  <p>This generates HTML:</p>
  <pre><code>&lt;input class=&quot;form-control text-box single-line&quot; data-val=&quot;true&quot; data-val-date=&quot;The field Start Date must be a date.&quot; data-val-required=&quot;The Start Date field is required.&quot; id=&quot;StartDate&quot; name=&quot;StartDate&quot; type=&quot;datetime&quot; value=&quot;21/10/2021&quot;&gt;
  </code></pre>
  <p>Now if I replace the helper code with this in my cshtml file and change <code>type=datetime</code> to <code>type=date</code>, everything renders beautifully and I get a handy date picker. Of course, behind the scenes this is an ugly hack and I would like a more elegant way of doing things.</p>
  <p>I have seen a lot of articles talking about getting a date picker via jQuery but this seems to be a bit overkill since HTML does this for you intrinsically.</p>
  <p>Can anyone offer some advice?</p>