How Can We Help?

Get Name of Month from ID

← All Topics

— ===================================================================================
— Author : Haroon Mushtaq Abbasi
— Create date : 03-11-2019
— Description : This function will return the name of month provided its ID/Number
— Test Query : SELECT [dbo].fnGetMonthName
— Test Query : SELECT [dbo].fnGetMonthName
— Test Query : SELECT [dbo].fnGetMonthName
— ===================================================================================
ALTER FUNCTION [dbo].[fnGetMonthName]
(

@MonthID as smallint

)
RETURNS varchar(20)
AS
BEGIN

DECLARE @ReturnVal as varchar(20)
SELECT @ReturnVal=DATENAME(month, DATEADD(month, @MonthID+1, GETDATE()))


RETURN @ReturnVal

END

Previous Convert a Delimited String to rows based on a delimiter
Next Get the First Day of a Month
Table of Contents