The VBA Day Function returns the day number (from 1 to 31) of a supplied date.
The syntax of the function is:
A simple example of the VBA Day function is shown below:
' Extract the day component from the date "11/29/2015"
Const currDate = "11/29/2015"
Dim dayNum As Integer
dayNum = Day(currDate)
' The variable dayNum is now equal to 29.
|
After running the above VBA code, the variable dayNum holds the value 29, (the day number of the date "11/29/2015").
If the Day function is supplied with a value that cannot be interpreted as a valid date, it will return the error: