VBA Now

Now Function Description

The VBA Now function returns the current system date and time.

It can be easily used to measure the time elapsed on Hours, Minutes and Seconds (see examples below).

VBA Now Syntax

The syntax for the Now function in VBA is:

Now()

Parameters

The function does not accept any parameters.

Other Notes

The VBA Now function returns a date variable with the date and time values. If you want just the current system time use the VBA Time function.

Example Usage

The Now function can be used in VBA code. Let’s look at some VBA Now function examples:

Now()
'Result example: 2016-01-26 15:01:40 

Measure time elapsed in Hours / Minutes / Seconds

You can also use the VBA Now function to measure the time elapsed in Hours, Minutes and Seconds between 2 time intervals:

Dim currTime as Date 

currTime = Now()
'... Some code here ...
Debug.Print Format(currTime  - Now(), "HH:MM:SS")
'Result for 10 minutes and 1 second: 00:10:01