Export (0) Print
Expand All
Expand Minimize
6 out of 10 rated this helpful - Rate this topic

MONTH (Transact-SQL)

Returns an integer that represents the month part of a specified date.

Topic link icon Transact-SQL Syntax Conventions


MONTH ( date )
date

Is an expression that returns a datetime or smalldatetime value, or a character string in a date format. Use the datetime data type only for dates after January 1, 1753.

MONTH is equivalent to DATEPART(mm, date).

Always enclose datetime values in quotation marks. For earlier dates, store dates as character data.

The Microsoft SQL Server 2005 Database Engine recognizes a variety of date styles. For more information about date and time data, see CAST and CONVERT (Transact-SQL).

The following example returns the number of the month from the date 03/12/1998.

SELECT "Month Number" = MONTH('03/12/1998')
GO

Here is the result set.

Month Number 
------------ 
3            

The following example specifies the date as a number. The Database Engine interprets 0 as January 1, 1900.

SELECT MONTH(0), DAY(0), YEAR(0)

Here is the result set.

----- ------ ------
1     1      1900
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.