Redigera

Dela via


DateAndTime.Month(DateTime) Method

Definition

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

public:
 static int Month(DateTime DateValue);
public static int Month (DateTime DateValue);
static member Month : DateTime -> int
Public Function Month (DateValue As DateTime) As Integer

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.

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

See also