对于x(@startDate)和y(@endDate)日期间隔。我希望能够在下周五增加,直到@endDate。
伪代码 init currentDate to startDate
循环直到endDate
将currentDate设为下周五
结束循环
我试过了:
set datefirst 5 /* Friday */
CASE
WHEN DATEPART(cdw, @currentDate) = @@datefirst THEN DATEADD(dd, 7, @currentDate)
ELSE DATEADD(dd, ( @@datefirst + ( DATEPART(cdw,@currentDate) ) ) % 7, @currentDate)
END
它不起作用......
答案 0 :(得分:0)
DATEADD(dd,(CASE DATEPART(cdw, @currentDate) WHEN 5 THEN 7 ELSE 5 - DATEPART(cdw,@currentDate) END),@currentDate)