try:
select * from table1 where datediff(mm,cast(rtrim(年)+'-'+rtrim(月)+'01' as datetime),日期)>5

解决方案 »

  1.   

    select * from tb where year(日期)>年+4 or month(日期)>月+4
      

  2.   

    如果大于5,则:
    select * from tb where year(日期)>年+5 or month(日期)>月+5
      

  3.   

    select * 
    from table1 
    where datediff(mm,cast(rtrim(年)+'-'+rtrim(月)+'-01' as datetime),日期)>5
      

  4.   

    select * from table1 where datediff(mm,cast(rtrim(年)+'-'+rtrim(月)+'-01' as datetime),日期)>5