walangala
walangala

Reputation: 241

Convert Date Format in Update Query

I'm trying to perform and update query that updates the date in a database. Please note, I'm using a version of SQL Server older than 2008 so I cannot use the Date type.

UPDATE TABLE
SET TABLE.DATECOLUMN = @input_date

I'm trying to do something like below, I want the date entered to essentially get rid of the time in datetime, so set it to midnight.

UPDATE TABLE
SET DATEADD(d, DATEDIFF(d, 0, TABLE.DATECOLUMN)) = @input_date

Upvotes: 0

Views: 1207

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522396

UPDATE TABLE
SET DATECOLUMN = CONVERT(DATETIME, DATEDIFF(DAY, 0, @input_date))

Upvotes: 2

Related Questions