Getting the Current Date and Time

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Three functions in VBA can tell you exactly when it is: the Now, Date, and Time functions. The Now function returns both the date and time portions of a Date variable. For example, calling the Now function from the Immediate window returns a value like this one:

2/23/98 6:16:47 PM

The Date function returns the current date. You can use it if you don't need to know the time. The Time function returns the current time, without the date.