Excel – Convert date from SQL text to Excel date format

microsoft excelsql server

I'm trying to export from my pervasive SQL database to Excel.
the date is stored as CHAR(8) I need them in a recognized date format for Excel so that I can use date filtering. What do I have to add to my SQL Query to convert this date? I tried looking on W3schools, but couldn't really find what I was looking for.

Here is my query:

SELECT DISTINCT ORDER_HIST_LINE.INVOICE, 
ORDER_HIST_LINE.ORDER_NO, 
ORDER_HIST_LINE.ORDER_LINE, 
ORDER_HIST_LINE.CUSTOMER, 
ORDER_HIST_LINE.NAME_CUST_SHIP, 
ATG_BRW_INVENTORY.DISPLAY_PART, 
ATG_BRW_INVENTORY.DISPLAY_REV, 
ORDER_HIST_LINE.CUSTOMER_PO, 
ORDER_HIST_LINE.DATE_SHIPPED,

Best Answer

You can use instead of ORDER_HIST_LINE.DATE_SHIPPED

select ....convert(ORDER_HIST_LINE.DATE_SHIPPED, getdate(), 103)
For 103 it is the format or type of date you can choose from this example which number you need.

Related Question