SQL根据指定月份获取当前季度

declare @dt datetime
set @dt = cast('2007-05-01' as datetime)

select datename(yy,@dt) + '-' + right('0'+cast(3 * (datepart(qq,@dt)-1) + 1 as varchar),2) + '月'
union
select datename(yy,@dt) + '年' + right('0'+cast(3 * (datepart(qq,@dt)-1) + 2 as varchar),2) + '月'
union
select datename(yy,@dt) + '年' + right('0'+cast(3 * (datepart(qq,@dt)-1) + 3 as varchar),2) + '月'

posted @ 2012-08-19 18:13  EasyPass  阅读(5765)  评论(0编辑  收藏  举报