日期:2014-05-18 浏览次数:20458 次
SELECT DATEDIFF(month, -1, Col1 + '-01') FROM TABLE1
------解决方案--------------------
--> 测试数据: @T declare @T table (dt varchar(7)) insert into @T select '2008-01' union all select '2008-05' union all select '2008-10' union all select '2008-12' select dt,convert(varchar(7),dateadd(month,-1,dt+'-01'),120) predt from @T /* dt predt ------- ------- 2008-01 2007-12 2008-05 2008-04 2008-10 2008-09 2008-12 2008-11 (4 row(s) affected) */