How to use the VBA DATE Function (Syntax + Example)

HomeVBA Functions LIST (Category Wise)How to use the VBA DATE Function (Syntax + Example)

The VBA DATE function is listed under the date category of VBA functions. When you use it in the VBA code, it returns the current date as per the system. It’s just like the TODAY function which you use in the worksheet. The Date returns have the mm/dd/yyyy format or the format which you have defined.

Syntax

Date()

Arguments

  • There’s no argument to define within the function.

Example

To practically understand how to use VBA DATE function, you need to go through the below example where we have written a vba code by using it:

Sub example_DATE()
Range("A1").Value = Date
End Sub

In the above example, we have used the DATE function to enter the current date into the cell A1.

Unlike the TODAY function, (which you can use in the worksheet) the date entered by the VBA DATE function is not volatile, so if you want to enter the current date again you need to run the code again.

Related Functions

DATEADD | DATEDIFF | DATEPART | DATESERIAL | DATEVALUE | DAY | MONTH | MONTHNAME | WEEKDAY | WEEKDAYNAME | YEAR