我的代码是
declare @StartDate datetime,@EndDate datetime,@hoursInAWorkday time
set @StartDate='10/07/2013 08:00:00'
set @EndDate='10/10/2013 17:00:00'
declare @time1 time = '00:00:00';
declare @time2 time = '09:00:00';
while @StartDate<@EndDate
Begin
set @StartDate=DATEADD(D,1,@StartDate)
set @time2= DATEADD(hh,9,@time1)
set @time1=@time2
End
这里9 + 9我得到18但在那之后我得到错误的答案.plz PLZ帮助我......
答案 0 :(得分:0)
您的代码不产生错误,并且03:00:00正确,因为您每个循环增加9小时