How can I get the month number in sql? I use the following code but it returns the month name.
SELECT DATENAME(mm, GETDATE())
You want DATEPART:
select datepart(mm, getdate())