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

Table of Contents