Now()

Syntax

Now()

Remarks

Returns a serial number that represents the current date and time according to
the computer's system date and time. Numbers to the left of the decimal point represent the number of days between December 30, 1899 and the current date; numbers to the right represent the time as a fraction of a day. For more information about serial numbers, see DateSerial().

Example

This example displays a message box stating the number of days until the new year. The number of days is calculated by subtracting the serial number for the current date and time from the serial number for January 1 of the following year.


yr = Year(Now())
rightNow = Now()
jan1 = DateSerial(yr + 1, 1, 1)
MsgBox "Days until the new year:" + Str$(jan1 - rightNow)

Fractions of a day appear in the result after the decimal point. To return strictly the number of days with no decimal fraction, substitute Today() in place of Now() in the preceding example.

See Also

DateSerial(), Date$(), DateValue(), Today()