TOP

VBA Function: Day

Description

The VBA Day function returns an integer corresponding to the day of the specified date.


Syntax Day

Day(date)

VBA Day Example

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

Sub DayExample1()
    
      myDate = #10/30/2020#
    
      MsgBox Day(myDate) 'Returns: 30

end sub

This function also accepts dates in text format:

Sub DayExample2()
    
      myDate = "30/10/2020"
    
      MsgBox Day(myDate) 'Returns: 30

end sub
The function returns the current month: MONTH.
A function that returns the current year: YEAR.