Muhammad
Muhammad

Reputation: 13

How to update a column (all rows) based on current value in SQL Server

I have a table in SQL Server with a column called "CreatedDate" (type: DateTime). I want to update all records by adding 3 hours to existing value. All rows are created on a different DateTime. If a record was created at 07:33 then after running the query it should have value 10:33.

Upvotes: 0

Views: 614

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521794

Use DATEADD:

UPDATE yourTable
SET CreatedDate = DATEADD(hour, 3, CreatedDate);

Upvotes: 1

Related Questions