SQL Server 2008 – How to Convert Date and Time

sql-server-2008

I have a column with about 100 records in datetime (for example 2004-08-09 12:20:41:000) and I would like to convert all records or update same time just date only with format mm-dd-yyyy.

Thank you.

Best Answer

Try converting the datetime column as follows:

UPDATE [TableName]
    SET DateCreate = CAST(LEFT(CONVERT(NVARCHAR(25), DateCreate, 120), 10) AS DATETIME)