SQL Server MONTH() Function

The MONTH() function in SQL Server extracts the month from a date or datetime value, returning a number between 1 and 12 (1 for January, 2 for February, and so on).



MONTH(): Definition and Usage

This function is very useful when you need to work with or filter data based on the month. For example, you might use it to generate monthly reports, analyze sales trends by month, or find all records related to a specific month.

Syntax

Syntax

MONTH(date)
      

Parameter Values

Parameter Description
date The date or datetime value from which you want to extract the month. This is required.

Examples

Extracting the Month from a Date

This example extracts the month from the date '2017/08/25'.

Syntax

SELECT MONTH('2017/08/25') AS Month;
      
Output

8
      

Extracting the Month from a Datetime

This example shows that MONTH() works equally well with datetime values.

Syntax

SELECT MONTH('2017/05/25 09:08') AS Month;
      
Output

5
      

Technical Details

Return Type: int (integer)

Works in:

  • SQL Server (starting with version 2008)
  • Azure SQL Database
  • Azure SQL Data Warehouse
  • Parallel Data Warehouse