sqlsql-servert-sqldatesql-convert

SQL Server Convert 01 December 2016 to date


How can one convert the string "01 December 2016" to a date type in SQL Server?

CONVERT(date, '01 December 2016', 106)

Expected date outcome "01 Dec 2016"


Solution

  • If 2012+ you can use Format()

    Select Format(convert(date,'01 December 2016'),'dd MMM yyyy')
    

    Returns

    01 Dec 2016