SQL Server: MONTH Function

MONTH function

This SQL Server tutorial explains how to use the MONTH function in SQL Server (Transact-SQL) with syntax and examples.

Description

In SQL Server (Transact-SQL), the MONTH function returns the month (a number from 1 to 12) given a date value.

Syntax

The syntax for the MONTH function in SQL Server (Transact-SQL) is:

MONTH( date_value )

Parameters or Arguments

date_value

The date from which to extract the month.

Note

Applies To

The MONTH functions can be used in the following versions of SQL Server (Transact-SQL):

  • SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005

Example

Let’s look at some SQL Server MONTH functions examples and explore how to use the MONTH functions in SQL Server (Transact-SQL).

For example:

SELECT MONTH('2014/04/28');
Result: 4

SELECT MONTH('2014/03/31 10:05');
Result: 3

SELECT MONTH('2014/12/01 10:05:18.621');
Result: 12

Leave a Reply