Excel VBA Day Function

The function Day in VBA returns the day number (from 1 to 31) for the given date value.

Syntax

Day (Date)

Parameter

Date (required) – This parameter represents the date.

Return

This function returns the day number (from 1 to 31) for the given date value.

Example 1

Sub DayFunction_Example1()
 ' Extracting the day element from the given date
 Const Date_Val = "10/02/2020"
 Dim Day_val As Integer
 Day_val = Day(Date_Val)
 ' The variable Day_val will return 2.
 Cells(1, 1).Value = Day_val
 End Sub 

Output

2

VBA Day Function

Example 2

Sub DayFunction_Example2()
 ' Extracting the day element from the current date
 Dim Date_Val As Date
 Date_Val = Date
 Dim Day_val As Integer
 Day_val = Day(Date_Val)
 ' The variable Day_val will return 8.
 Cells(1, 1).Value = Day_val
 End Sub 

Output

8

VBA Day Function