我有同样的问题,因为问这个问题的人。其他答案没有解决他的问题。
他所拥有的是变量,需要通过递增来改变日期。你在正确的轨道上。
这里是一个演示,你可以复制并粘贴到SSMS,它会工作。
/*First declare your varabiles, you can use date or datetime, or even var only after using dateadd the format will change */
Declare @CTCStartDate date
Declare @CTCEndDate date
/* Now define your initial values, you may want to have these by a SSRS report or other program */
Set @CTCStartDate = '2015-01-01'
Set @CTCEndDate = '2015-11-11'
/* See the inital values */
Select @CTCStartDate as InitialStartDT, @CTCEndDate as InitialEndDT
/* Increment the year by the number you desire, even this can be a variable */
Set @CTCEndDate = DATEADD(YYYY,1, @CTCEndDate)
Set @CTCStartDate = DATEADD(YYYY,1, @CTCStartDate)
/* See the final results */
Select @CTCStartDate as StartDT, @CTCEndDate as EndDT
先生,我修改了我的问题。请回复。 – sriramjitendra 2011-01-20 07:13:20