DateAndTime.Month(DateTime) Method
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
- DateValue
- DateTime
Required. A Date
value from which you want to extract the month.
An integer value from 1 through 12 representing the month of the year.
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.
You can also obtain the month of the year by calling DatePart
and specifying DateInterval.Month
for the Interval
argument.
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 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: