当前位置: 代码迷 >> Sql Server >> 在MS-SQL中,怎么获取上个月的月份
  详细解决方案

在MS-SQL中,怎么获取上个月的月份

热度:66   发布时间:2016-04-24 22:54:35.0
在MS-SQL中,如何获取上个月的月份
在MS-SQL中,如何获取上个月的月份?
例如,目前是2013年4月,则自动获得2013年3月;
如果目前是2013年1月,则自动获得2012年12月

------解决方案--------------------
select convert(varchar(7),dateadd(month,-1,getdate()),120)
------解决方案--------------------
select replace(substring(convert(varchar(32),dateadd(month,-1,getdate()),120),1,7),'-','年')+'月'
------解决方案--------------------
select replace(convert(varchar(7),dateadd(month,-1,getdate()),120),'-','年')+'月'
  相关解决方案