String To Date format
<p>I have a <code>jQuery calender</code> which has values in an <code>ASP Textbox</code> (not editable bar via the calender)</p>

<p>The two calender's create a From and To date. (Including defaults)</p>

<p>I need to convert the <code>string</code> from <code>dd/mm/yyyy</code> to <code>yyyy-MM-dd</code> but despite trying various stack ideas get below err-</p>

<blockquote>
  <p>Error: Conversion failed when converting date and/or time from
  character</p>
</blockquote>

<p>Code:</p>

<pre><code> Dim vDateFrom As Date = sDateFrom.Text
        vDateFrom = vDateFrom.ToString("yyyy-MM-dd")
        Dim vDateTo As Date = sDateTo.Text
        vDateTo = vDateTo.ToString("yyyy-MM-dd")
</code></pre>

<p>The <code>SQL</code> it runs works if I override the above with:</p>

<pre><code>vDateFrom = 2016-03-01
 vDateTo = 2016-06-01
</code></pre>

<p>When I debug it appears the date is still <code>dd/mm/yyyy</code> i.e. <code>#6/15/2016 12:00:00 AM#</code></p>

<p>I've also included the SQL string line (test) encase I can simply change the date there.</p>

<pre><code>Using command As New SqlCommand("Select COUNT(d.ID) FROM TblData As D  JOIN TBLPROPERTYLIST As p On d.UPRN = p.UPRN WHERE 1 = 1 And d.SurveyDate between '" &amp; vDateFrom.ToString &amp; "' AND '" &amp; vDateTo.ToString &amp; "' And d.Field1 = " &amp; i &amp; " And d.Field2 = " &amp; j &amp; "" &amp; vString &amp; "", connection)
</code></pre>

<p><strong>Notes:</strong></p>

<p>Looked at among others:</p>

<p>-Adding CDate and also</p>

<p>-<a href="https://stackoverflow.com/questions/17418258/datetime-format-to-sql-format-using-c-sharp#">datetime format to SQL format using C#</a></p>