Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Month number to display Name of Month

Status
Not open for further replies.

Cpreston

MIS
Mar 4, 2015
972
GB
Hi

I have a View that works ok but it is displaying the calendarMonth as a number 1,2,2 etc... which I would like to display as January, Feb March etc....

Any ideas how I can change the code below so this will work please. Thanks


SELECT dbo.Product.ProductID, dbo.Product.ProductCode, dbo.Product.Description, dbo.ProductAnalysis.CalendarYear, dbo.ProductAnalysis.CalendarMonth,
dbo.ProductAnalysis.TotalVolume, dbo.ProductStockOption.StockLevelMin, dbo.ProductStockOption.StockLevelMax, dbo.ProductGroup.Name,
dbo.ProductStockOption.BranchID
FROM dbo.Product INNER JOIN
dbo.ProductAnalysis ON dbo.Product.ProductID = dbo.ProductAnalysis.ProductID INNER JOIN
dbo.ProductGroup ON dbo.Product.ProductGroupID = dbo.ProductGroup.ProductGroupID INNER JOIN
dbo.ProductStockOption ON dbo.Product.ProductID = dbo.ProductStockOption.ProductID
WHERE (dbo.ProductAnalysis.CalendarYear = 2015) AND (dbo.ProductStockOption.BranchID = 1)
 
Since the number is coming from a column and not a date my suggestion would be a case statement. You could possibly also use a cross apply.

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Create a new table with month number in one field and text month in another field then create a new join on month number.

Simi
 
Hi

Thanks for the reply's, I got it working using the below in the select

SELECT TOP (100) PERCENT dbo.Product.ProductID, dbo.Product.ProductCode, dbo.Product.Description, dbo.ProductAnalysis.CalendarYear, DATENAME(month,
DATEADD(month, dbo.ProductAnalysis.CalendarMonth - 1, 0))
AS Monthname, dbo.ProductAnalysis.TotalVolume, dbo.ProductStockOption.StockLevelMin,
dbo.ProductStockOption.StockLevelMax, dbo.ProductGroup.Name, dbo.ProductStockOption.BranchID, dbo.ProductGroup.ParentID,
dbo.ProductGroup.Deleted
FROM dbo.Product INNER JOIN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top