title: VBA: How to get date as a string yyyy-mm-dd
body: <p>I am trying to get the Date as a string formatted <code>yyyy-mm-dd</code>.</p>
  
  <p>I have tried various things with strange results:</p>
  
  <pre><code>Dim mydate As String
  mydate = Date
  mydate = Year(Date)
  mydate = Month(Date)
  mydate = Day(Date)
  </code></pre>
  
  <ol>
  <li>The first one gives <code>11/02/</code> without the year.</li>
  </ol>
  
  <p>I can try to concatenate the data but:</p>
  
  <ol start="2">
  <li>The second gives the year OK</li>
  <li>However the third gives month as 2 instead of 02</li>
  <li>Similar for fourth.</li>
  </ol>
  
  <p>Any clarification or an example would be very welcome.</p>