Partager via


DateAndTime.Month Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

Syntax

'Declaration
Public Shared Function Month ( _
    DateValue As DateTime _
) As Integer
public static int Month(
    DateTime DateValue
)

Parameters

  • DateValue
    Type: System.DateTime
    Required. Date value from which you want to extract the month.

Return Value

Type: System.Int32
Returns an Integer value from 1 through 12 representing the month of the year.

Remarks

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

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.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.