2017-11-24 8 views
-1

을 변경하는 방법을 알고 싶어, 내가 초래 할내가 날짜 예를 들어

2017-11-22 05:00:00 
2017-11-22 05:30:00 
2017-11-23 05:45:00 
2017-11-23 05:50:00 
2017-11-24 06:00:00 
2017-11-24 06:30:00 
2017-11-24 06:05:00 

Day 22 is +1 day from current date 
Day 23 is +2 days from the current date 
The 24th day is +3 days from the current date. 

DB를의 날짜는 ...입니다 :

내가 이런 식으로 변경하려면 .

2017-11-25 05:00:00 
2017-11-25 05:30:00 
2017-11-26 05:45:00 
2017-11-26 05:50:00 
2017-11-27 06:00:00 
2017-11-27 06:30:00 
2017-11-27 06:05:00 

시도했지만 실패했습니다.

update Info_Game set IG_StartTime = replace(convert(char(10), IG_StartTime, 20), '2017-11-22', convert(char(10), getdate()+1, 20)) 
update Info_Game set IG_StartTime = replace(convert(char(10), IG_StartTime, 20), '2017-11-23', convert(char(10), getdate()+2, 20)) 
update Info_Game set IG_StartTime = replace(convert(char(10), IG_StartTime, 20), '2017-11-24', convert(char(10), getdate()+3, 20)) 

답변

0

시도해보십시오.

update Info_Game set IG_StartTime = DATEADD(day,1,DATEADD(hour,DATEPART(hour,IG_StartTime),cast(getdate() as date))) where cast(IG_StartTime as date) = '2017-11-22' 

update Info_Game set IG_StartTime = DATEADD(day,2,DATEADD(hour,DATEPART(hour,IG_StartTime),cast(getdate() as date))) where cast(IG_StartTime as date) = '2017-11-23' 

update Info_Game set IG_StartTime = DATEADD(day,3,DATEADD(hour,DATEPART(hour,IG_StartTime),cast(getdate() as date))) where cast(IG_StartTime as date) = '2017-11-24'