title: Dates from SQL Query
body: <p>This is perhaps a very simple question.</p>
  
  <p>I have a very basic query in Excel that pulls in some values from a db on Sql Server 2008 R2.</p>
  
  <p>The date fields in this db are stored as datetime. In this query, I am uninterested in the time part, and so only want to select the date. I have tried using Cast or Convert, however both return the date in sql (yyyy-mm-dd) to Excel. Excel recognizes this as text rather than a date, and so I am unable to do date filters in my table once the data is in Excel.</p>
  
  <p>If I do datepart() in Excel, it shows it as a date and I can filter as expected, however I want the data coming directly from the query to return as a date value that Excel can filter on.</p>
  
  <p>Below is my sample query:</p>
  
  <pre><code>SELECT order_header.oh_id, 
  order_header.oh_order_number, 
  order_header.oh_datetime, 
  convert(date, order_header.oh_datetime, 103) as 'ConvertOrderDate',
  cast(order_header.oh_datetime as date) as 'CastOrderDate'
  FROM order_header
  WHERE order_header.oh_datetime &gt;= '2013-09-01'
  </code></pre>
  
  <p>When returning this to Excel, this is what is being returned:</p>
  
  <p><a href="http://img834.imageshack.us/img834/4417/7gbg.png" rel="nofollow noreferrer">Output Image http://img834.imageshack.us/img834/4417/7gbg.png</a></p>