--取时间大于等于4个月前的数据(也就是最近4个月的数据)
declare @mytime datetime = DATEADD(month,-4,getdate())
select
*
from T_1
where left(WorkYearMonth,4)>=year(@mytime)
and right(WorkYearMonth,2)>=month(@mytime)
--取时间大于等于4个月前的数据(也就是最近4个月的数据)
declare @mytime datetime = DATEADD(month,-4,getdate())
select
*
from T_1
where left(WorkYearMonth,4)>=year(@mytime)
and right(WorkYearMonth,2)>=month(@mytime)
转载于:https://my.oschina.net/dapsjj/blog/2975978