How can I get the month number (not month name) from a date in SQL Server?

前端 未结 7 1576
孤街浪徒
孤街浪徒 2021-02-02 08:37

How can I get the month number in sql? I use the following code but it returns the month name.

SELECT DATENAME(mm, GETDATE())
相关标签:
7条回答
  • 2021-02-02 09:04

    Use Datepart:

    DATEPART(mm,getdate());
    
    0 讨论(0)
提交回复
热议问题