;

To convert month number to month name in SQL Server


Tutorialsrack 11/06/2019 SQL SQL Server

In this post, we will learn how to convert Month Number to Month Name in SQL Server.

I think this is the best way to get the month name when you have the month number.

Here is the query to convert the month number to month name in SQL Server.

1st Example - 
Declare @MonthNumber int=1;

SELECT DATENAME(MONTH, DATEADD(MONTH, @MonthNumber , 0 ) - 1 ) As 'Month Name';
Output

Month Name
------------------------------
January

2nd Example
Declare @MonthNumber int=1;

Select DATENAME(MONTH, DATEADD(MONTH, @MonthNumber, -1 ) ) As 'Month Name';
Output

Month Name
------------------------------
January

I hope this article will help you to understand to convert month number to month name in SQL Server

Share your valuable feedback and help us to improve. If you find anything incorrect, or you want to share more information about the topic discussed above. please post your comment at the bottom of this article. Thank you!


Related Posts



Comments

Recent Posts
Tags