Returning Month Name in SQL Server Query

后端 未结 11 1011
情深已故
情深已故 2020-12-13 03:39

Using SQL Server 2008, I have a query that is used to create a view and I\'m trying to display a month\'s name instead of an integer.

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 04:05

    basically this ...

    declare @currentdate datetime = getdate()
    select left(datename(month,DATEADD(MONTH, -1, GETDATE())),3)
    union all
    select left(datename(month,(DATEADD(MONTH, -2, GETDATE()))),3)
    union all
    select left(datename(month,(DATEADD(MONTH, -3, GETDATE()))),3)
    

提交回复
热议问题