Get month and year from a datetime in SQL Server 2005

后端 未结 20 1536
[愿得一人]
[愿得一人] 2020-12-12 15:39

I need the month+year from the datetime in SQL Server like \'Jan 2008\'. I\'m grouping the query by month, year. I\'ve searched and found functions like datepart, convert, e

20条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 16:25

    returns the full month name, -, full year e.g. March-2017

    CONCAT(DATENAME(mm, GetDate()), '-', DATEPART(yy, GetDate()))
    

提交回复
热议问题