title: How to sort Varchar Date in SQL Server 2000
body: <p>My table schema (table Name Stock)</p>
  
  <p><strong>Field</strong></p>
  
  <pre><code>Date Datetime
  </code></pre>
  
  <p>If <code>Date</code> having datatype is <code>Datetime</code> then SQL Server sorts the date in well/perfect order.  See Below Example.</p>
  
  <pre><code>select date from stock order by date
  </code></pre>
  
  <p>Then result is:</p>
  
  <pre><code>Date(yyyy/MM/dd)
  2010-04-02 00:00:00.000
  2011-02-02 00:00:00.000
  2011-02-03 00:00:00.000
  2011-02-03 00:00:00.000
  </code></pre>
  
  <p>But if I am going to sort the same by casting varchar than it will be ultimately create problem and the problem is it will not sort date by date order as it is now casting in Varchar.</p>
  
  <p>Look at example below:</p>
  
  <pre><code>select date = convert(varchar, date, 103) from stock order by date
  </code></pre>
  
  <p>Then result is:</p>
  
  <pre><code>Date(dd/MM/yyyy)
  02/02/2011
  02/04/2010
  03/02/2011
  03/02/2011
  </code></pre>
  
  <p>You can see second query’s result that it will not sort date in order as because it is now not in datetime datatype. It is casting as varchar or you can say it as string.</p>
  
  <p>Now come to the point that:</p>
  
  <p>If I want to sort date which is casting in varchar order by date than how to do it?.</p>