Export (0) Print
Expand All
ABS
ALL
AND
ANY
AVG
bit
COS
COT
DAY
EXP
GO
IN
LEN
LOG
MAX
MIN
NOT
OR
PI
SET
SIN
STR
SUM
TAN
USE
VAR
Expand Minimize

MONTH

SQL Server 2000

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

Syntax

MONTH ( date )

Arguments

date

Is an expression returning 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.

Return Types

int

Remarks

MONTH is equivalent to DATEPART(mm, date).

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

Microsoft® SQL Server™ recognizes a variety of date styles. For more information about date and time data, see CAST and CONVERT.

Examples

This 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            

This example specifies the date as a number. Notice that SQL Server interprets 0 as January 1, 1900.

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

Here is the result set.

----- ------ ------
1     1      1900

See Also

Data Types

Date and Time Functions

datetime and smalldatetime

Show:
© 2014 Microsoft