Using SQL Server 2008
, I have a query that is used to create a view and I\'m trying to display a month\'s name instead of an integer.
In SQL Server 2012 it is possible to use FORMAT(@mydate, 'MMMM') AS MonthName
Select SUBSTRING (convert(varchar,S0.OrderDateTime,100),1,3)
from your Table Name
Have you tried DATENAME(MONTH, S0.OrderDateTime)
?
basically this ...
declare @currentdate datetime = getdate()
select left(datename(month,DATEADD(MONTH, -1, GETDATE())),3)
union all
select left(datename(month,(DATEADD(MONTH, -2, GETDATE()))),3)
union all
select left(datename(month,(DATEADD(MONTH, -3, GETDATE()))),3)
This will give you what u are requesting for:
select convert(varchar(3),datename(month, S0.OrderDateTime))