Function to Extract Month from Date in SQL Server

A function to extract month from date is a most common question in forums. Month part from a date can be extracted as shown below

SELECT MONTH(GETDATE()) AS [Month]
GO
SELECT CONVERT(varchar(4),GETDATE(),100) AS [Month]
GO
SELECT DATEPART(Month,GETDATE()) AS [Month]
GO
SELECT DATEPART(MM,GETDATE()) AS [Month]
GO
SELECT DATENAME(mm,GETDATE()) AS [Month]
GO
-- Available SQL Server 2012 onwards
SELECT FORMAT( GETDATE(), 'MMMM') AS 'DateTime Result'

function to extract month from date in sql server

   

 

Like us on FaceBook Join the fastest growing SQL Server group on FaceBook

   

Leave a Reply

Your email address will not be published.