where datediff(mm,monthstart,monthend)>lhzq

解决方案 »

  1.   

    where datediff(mm,monthstart,monthend)+datediff(mm,azrq,monthstart)>lhzq
      

  2.   

    where azrq between monthstart and monthend
    and ado.faddday(azrq,@lhzq,@type) between monthstart and monthedn--@type指周期类型,可以为年、月、周、天、季度等
      

  3.   

    create function faddday
    (@date1 datetime,
    @lhzq int,
    @type nchar(1))
    returns datetime
    as
    begin
    declare @out datetime
    select @out = case 
    when @type='年' then dateadd(year,@lhzq,@date1)
    when @type='月' then dateadd(month,@lhzq,@date1)
    when @type='日' then dateadd(day,@lhzq,@date1)
    when @type='周' then dateadd(week,@lhzq,@date1)
    when @type='季' then dateadd(quarter,@lhzq,@date1)
    else @date1
    end
    return @out
    end