Search
Close this search box.

VBA – Date


The Date() function in VBA is a powerful tool for working with dates within your Excel macros. It provides a simple and efficient way to:

  • Obtain the Current Date:
    • The primary function of Date() is to return the current system date.
    • This is invaluable for timestamping events, creating dynamic reports, and performing date-based calculations.

Syntax:

Date()

Example

				
					Dim todaysDate As Date
todaysDate = Date() 
MsgBox "Today's Date: " & todaysDate
				
			

The above code snippet will display a message box with the current date in the default system format.