DateAndTime.Month(DateTime) Method

Definition

Returns an integer value from 1 through 12 representing the month of the year.

C#
public static int Month(DateTime DateValue);

Parameters

DateValue
DateTime

Required. A Date value from which you want to extract the month.

Returns

An integer value from 1 through 12 representing the month of the year.

Examples

This example uses the Month function to obtain the month from a specified date. In the development environment, the date literal is displayed in short date format using the locale settings of your code.

VB
Dim thisDate As Date
Dim thisMonth As Integer
thisDate = #2/12/1969#
thisMonth = Month(thisDate)
' thisMonth now contains 2.

Remarks

You can also obtain the month of the year by calling DatePart and specifying DateInterval.Month for the Interval argument.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also