晨风

-------------------- 业精于勤,荒于嬉;行成于思,毁于随

导航

sql如何获取一个时间段内的月份

Posted on 2016-02-04 09:22  shenyixin  阅读(1832)  评论(0编辑  收藏  举报
select convert(varchar(7),dateadd(month,number,'2010-01-01'),120)
from master..spt_values
where type='P' and dateadd(month,number,'2010-01-01')<='2010-09-01'
/*
-------
2010-01
2010-02
2010-03
2010-04
2010-05
2010-06
2010-07
2010-08
2010-09

*/