How can I convert the date 2009-01-27 11:47:00.000 to 24 Jan 2009 but also be able to retain date datatype to be able to sort as date not alphabetically?
I.e. date sort order
24 Jan 2009
03 Feb 2009
NOT
03 Feb 2009
24 Jan 2009
Thank you.
How can I convert the date 2009-01-27 11:47:00.000 to 24 Jan 2009 but also be able to retain date datatype to be able to sort as date not alphabetically?
I.e. date sort order
24 Jan 2009
03 Feb 2009
NOT
03 Feb 2009
24 Jan 2009
Thank you.
You can convert it to a string in your select, but still order by on the actual column:
Select CONVERT(varchar(11), Orders.ShipDate, 6) As FormatedDate
FROM Orders
Order by ShipDate Desc
SELECT PrettyDate = CONVERT(CHAR(11), ShipDate, 106)
FROM dbo.Orders
ORDER BY CONVERT(DATE, ShipDate), customer_no;