Jin Yong
Jin Yong

Reputation: 43768

How can I make change for existing date value in SQL Server into new value?

Does anyone know how can I make change for existing date value in SQL Server into new value?

Example:

Declare @StartDate DATETIME; SET @StartDate = '2010-07-07 00:00:00'

Which I hope to declare another variable @DATETIME2 DATETIME based on @StartDate value changed into '2010-07-07 08:00:00' instead of default manually hard code it

Upvotes: 0

Views: 270

Answers (1)

Joel Coehoorn
Joel Coehoorn

Reputation: 415620

Use the DateAdd() function:

DECLARE @DateTime2 DateTime; Set @DateTime2 = DATEADD(hh, 8, @StartDate)

Upvotes: 1

Related Questions