Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

DateAndTime.Month(DateTime) Method

Definition

Namespace:
Microsoft.VisualBasic
Assembly:
Microsoft.VisualBasic.Core.dll
Assembly:
Microsoft.VisualBasic.dll
Source:
DateAndTime.vb
Source:
DateAndTime.vb
Source:
DateAndTime.vb
Source:
DateAndTime.vb
Source:
DateAndTime.vb

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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


Feedback

Was this page helpful?