Last Updated: 14th February 2026
Let us assume, I have a Sales table with sales data for each month. Every day sales is stored in the table with columns such date, quantity, price etc. I want to get the total sales for every month. Now since I have a column with date data type, I want to convert the month number (in the date) to Month Name (like February, March etc.). I'll show you how this is done. Its very simple.
The Sales table
Let's create a table first in SQL Server.
CREATE TABLE [dbo].[Sales](
[SalesID] [int] NOT NULL,
[Quantity] [int] NULL,
[Price] [numeric](18, 2) NULL,
[SalesDate] [datetime] NULL,
)The table has four columns with a SalesDate column with type datetime. You can use the date type too.
Insert some data to the table
INSERT INTO dbo.Sales (SalesID, Quantity, Price, SalesDate) VALUES (1, 21, 11000, '2025-02-15'), (2, 3, 2000, '2025-02-09'), (3, 15, 21000, '2025-02-27'), (4, 28, 51000, '2025-03-02'), (5, 9, 6200, '2025-03-05')
Every row in the table now has quantities sold for the day, along with the price and the date on which the products are sold. The date has months in numbers, however, I wish to convert the month number to name, such as, 2 to February, 3 to March etc.
Get the Month Name from Number
Use this query to convert month in numbers month name.
SELECT DATENAME (MONTH, DATEADD(MONTH, MONTH(SalesDate) - 1, '1900-01-01')) Month, SUM(Quantity) Qantities_Sold, SUM(Price) Amount FROM dbo.Sales GROUP BY MONTH(SalesDate)
The Result:

In the above query, I am using the built-in DATENAME() function to get the string value of a specified datepart (such as MONTH) of a given date.
Syntax DATENAME
DATENAME ( datepart, date )
You can use the DATENAME() function to get the current day, month and year. For example,
SELECT DATENAME (DAY, GETDATE()) Today,
DATENAME (MONTH, GETDATE()) Current_Month,
DATENAME (YEAR, GETDATE()) Curreny_YearNow, by using the DATENAME() function, I can directly convert the month number in a date into its corresponding month name. For example,
SELECT DATENAME(MONTH, SalesDate) Month FROM dbo.Sales
However, when I apply the SUM() function to calculate the total price and quantities sold for each month, the query doesn't produce the expected result (see image above).
To resolve this, I combine the DATEADD() function with DATENAME(). The built‑in DATEADD() function adds a specified time interval to a date, and when used together with DATENAME(), it produces the correct month names alongside the aggregated totals.
SELECT DATENAME (MONTH, DATEADD(MONTH, MONTH(SalesDate) - 1, '1900-01-01')) Months FROM dbo.Sales

Finally, I'll use MONTH (SalesDate) in my query's GROUP BY clause to get the total price and quantity for each month (without repeating the months).
That’s it. Hope this is useful.
