title: SQL Server string to date conversion
body: <p>I have the following query:</p>
  
  <pre><code>SELECT  o.OrderNumber,
      cast(o.DateOrdered as datetime),
      cast(oi.Category as varchar(max))
  
   FROM   Orders o
      LEFT OUTER JOIN OrderItems oi ON oi.OrderID = o.uid
      LEFT OUTER JOIN OrderAddresses oa ON oa.OrderID = o.uid
  
   WHERE O.DateOrdered LIKE '6%2011%' AND (oa.Type = '4') AND (oa.Country = 'US')
  
   GROUP BY cast(oi.Category as varchar(max)), cast(o.DateOrdered as datetime), o.OrderNumber
  </code></pre>
  
  <p>I'm having trouble formatting the <code>datetime</code> as <code>mm/dd/yyyy</code>. No matter what I have tried I keep getting like <code>YYYY-MM-DD 00:00:00:000</code>. I must overlooking something simple in the syntax and was hoping someone could point me in the right direction?  (SQL Server 2005)</p>
  
  <p>Thanks!</p>