This is perhaps a very simple question.
I have a very basic query in Excel that pulls in some values from a db on Sql Server 2008 R2.
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.
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.
Below is my sample query:
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 >= '2013-09-01'
When returning this to Excel, this is what is being returned:
Output Image http://img834.imageshack.us/img834/4417/7gbg.png
datetry changing it todatetime