TOP

VBA Function: Month

YouLibreCalc for Excel logo

Description

The VBA Month function returns an integer that corresponds to the month of the specified date.


Syntax Month

Month(date)

VBA Month Example

Using the Month function to get the relevant information from a date:

Sub MonthExample1()
    
      maDate = #10/30/2020#
    
      MsgBox Month(maDate) 'Returns: 10

end sub

This function also accepts dates in text format:

Sub MonthExample2()
    
      maDate="10/30/2020"
    
      MsgBox Month(maDate) 'Returns: 10

end sub
The function returns the current day: DAY.
A function that returns the current year: YEAR.