Get Today Date in VBA

In VBA, you may get today’s date by: 1- Using Date() function 2- Now() function

How to get today’s date in VBA?

In VBA, you may get today’s date by:

  • Using Date() function
  • Now() function

First Way – An example to get today’s date by Date() function

We declared a date-type variable and assigned it the Date().

Then we displayed that in the message box.

VBA program:

Output:

VBA-today-date

Display today’s date in day, Month year format

By using Date() function in the Format() function, you may get the date in the desired format.

In this example, we will get today’s date in day, Month year name format. For example,

21 March, 2021

Code:

Output:

VBA-today-dd-mmmm-yyyy

Notice that, we declared a variable of String type. If you use a date type variable, it will not format the date.

Short Month name with Day and Year

For example, 21 Mar, 2021.

For that, use three times mmm:

Code:

Output:

VBA-today-short-month

Second way – Using Now() function to get today’s date

In this way, we will get today’s date by using the Now() function.

Now() function returns the current date and time.

Output:

VBA-today-Now

You see, not only it displays today’s date but time also.

Get only the date part by Now() function

Output:

VBA-today-date-only

You may use the same formatting options as shown with the Date() function above.