Export (0) Print
Expand All

Month Function (Visual Basic)

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

Public Function Month(ByVal DateValue As DateTime) As Integer

DateValue

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

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

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.

Namespace: Microsoft.VisualBasic

Module: DateAndTime

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Community Additions

ADD
Show:
© 2015 Microsoft