Reputation: 93
My input is month and year in integer.
I want the output as month and year concatenated as month name and year.
Please help me on this issue.
Upvotes: 3
Views: 417
Reputation: 24046
try this:
Use the DateName function to find the month_name, But that function requires a date value as input, so converting the month number to a date in the inside query..
declare @month int=3
declare @year int=2012
Select DateName( month , DateAdd( month , @month , 0 ) - 1 )
+' '+cast( @year as char(4))
result:
March 2012
Upvotes: 2
Reputation: 66687
Here's another solution:
declare @month int
declare @year int
select @month = 3
select @year = 2012
select datename(month , dateadd(mm, @month, '20120101')) + ' ' + cast(@year as char(4))
Upvotes: 1