TOP

VBA Function: Date

Description

The VBA Date function returns the current system date.


Date Syntax

Date

VBA Date Example

Storing the date returned by the Date function in cell A1:

Sub DateExample()

      Range("A1") = Date
    
end sub

Display the date returned by the Date function in text format:

Sub DateExample2()

      MsgBox Format(Date, "d mmmm yyyy") 'Returns, for example: 2 November 2020
    
end sub

Perform the action only if the date returned by the Date function is the first day of the month:

Sub DateExample3()

      If Day(Date) = 1 Then
          MsgBox "It's the first day of the month!"
      End if
    
end sub
The function that returns the current date and current time is the NOW function.