In my earlier article, we have seen how to get the day of week in name or number using the DATENAME and DATEPART inbuilt functions in SQL Server. Today we’ll see a simple tip on how to get the name of month using the same function DATENAME.
Syntax
DATENAME ( month , <date> )
Where the first parameter can be either month or mm or m. The second parameter should be a date datatype.
Example To Get Name of Month
SELECT DATENAME(month, GetDate())
/* Result */
June
Reference
- About the in-build function DATENAME at Microsoft Docs.