Getting Current Date in VBA: Date, Now, and Format

VBA & macros · Updated November 23, 2026

To get the current date in VBA, use the Date function, which returns today’s date as a Date data type. If you also need the current time, use Now instead. Both are built-in VBA functions with no arguments, so you can assign them directly to a variable or use them in a formula.

What Date and Now Actually Return

In VBA, Date returns the system date (based on your computer’s clock) with the time portion set to midnight (00:00:00). Now returns both the current date and the current time. For example:

Dim todayDate As Date
todayDate = Date   ' e.g., 2025-04-08

Dim currentMoment As Date
currentMoment = Now   ' e.g., 2025-04-08 14:35:22

Both functions read the operating system’s clock, so they reflect the local time zone and any manual changes you make to the system time. They do not depend on Excel’s calculation settings or the workbook’s location.

Using Date and Now in Excel Cells or Formulas

You can write the current date to a cell directly from VBA:

Range("A1").Value = Date
Range("B1").Value = Now

If you want to insert a live formula that updates when the workbook recalculates, use Formula instead:

Range("C1").Formula = "=TODAY()"   ' date only
Range("D1").Formula = "=NOW()"     ' date and time

Note that TODAY() and NOW() are worksheet functions, not VBA functions. They recalculate when Excel recalculates, whereas Date and Now in VBA only update when the code runs.

Formatting the Current Date as a String

Often you need the date as a text string, for example in a filename or a message box. Use Format to control the display:

Dim dateString As String
dateString = Format(Date, "yyyy-mm-dd")   ' 2025-04-08
dateString = Format(Date, "dd mmmm yyyy") ' 08 April 2025
dateString = Format(Now, "hh:mm:ss")     ' 14:35:22

The format codes are the same as those used in Excel’s TEXT function. Common ones include:

  • yyyy – four-digit year
  • mm – two-digit month (01–12)
  • dd – two-digit day (01–31)
  • mmm / mmmm – abbreviated / full month name
  • hh:mm:ss – time with hours, minutes, seconds

Be careful with mm: it means month when used with a date, but minutes when used with a time. Always test your format string.

Getting the Date Without the Time (and Vice Versa)

If you have a Now value and want only the date part, use DateValue or Int. The Date data type stores the date as a whole number and the time as a fraction, so:

Dim fullNow As Date
fullNow = Now
Dim onlyDate As Date
onlyDate = DateValue(fullNow)   ' strips time
Dim onlyTime As Date
onlyTime = fullNow - Int(fullNow)   ' fractional part

DateValue is clearer than Int because it explicitly converts any date/time expression to a date-only value. To get only the time, subtract the integer part; the result is a Date that represents a time on 1899-12-31 (the base date in Excel).

Common Pitfalls and Misconceptions

One frequent mistake is assuming Date returns a string. It returns a Date data type, which displays according to your system’s regional settings. If you compare it to a string literal, VBA will try to convert it, which can cause errors if the format doesn’t match.

Another issue is using Date in a worksheet formula within VBA. For example, Range("A1").Formula = "=Date()" will produce a #NAME? error because DATE() is a worksheet function that requires arguments (year, month, day). Use TODAY() for the current date in a formula.

Also, remember that VBA’s Date and Now are not volatile in the same way as worksheet functions. They do not automatically update when the workbook recalculates; they only update when the macro runs. If you need a timestamp that updates every time the sheet recalculates, use TODAY() or NOW() in the cell, not VBA.

Alternatives: Timer, GetSystemTime, and DateAdd

For high-resolution timing, VBA has a Timer function that returns the number of seconds since midnight with fractional precision. It’s useful for measuring how long code takes:

Dim startTime As Single
startTime = Timer
' ... run code ...
Dim elapsed As Single
elapsed = Timer - startTime

If you need the system date/time in UTC (Coordinated Universal Time), VBA doesn’t have a direct function, but you can use the Windows API GetSystemTime via Declare. This is advanced and requires care with 32-bit vs 64-bit Office. For most purposes, Date and Now are sufficient.

To add or subtract days, use DateAdd:

Dim tomorrow As Date
tomorrow = DateAdd("d", 1, Date)

This is safer than Date + 1 because it handles month/year boundaries correctly.

Frequently Asked Questions

How do I get the current date in a specific format like MM/DD/YYYY?

Use Format(Date, "MM/DD/YYYY"). The letters are case-sensitive in some cases: MM gives two-digit month, DD two-digit day, YYYY four-digit year. If you want a single-digit month without leading zero, use M instead of MM.

What’s the difference between Date and Now in VBA?

Date returns only the current date, with the time set to 00:00:00. Now returns both the current date and the current time. If you only need the date, use Date; if you need a timestamp, use Now.

Can I use VBA to insert the current date into a cell that updates automatically?

If you write Range("A1").Value = Date, the cell gets a static value that won’t change when the workbook is reopened. To make it update automatically, use Range("A1").Formula = "=TODAY()" instead. That formula recalculates each time Excel recalculates.

Why does my VBA code return a date one day off?

This usually happens when you convert a date to a string and back, or when you use DateValue with a string that has a different regional format. For example, if your system uses DD/MM/YYYY and you pass “04/08/2025”, VBA might interpret it as April 8 or August 4 depending on the locale. Always use Format to control the output, and avoid relying on string conversions.

How do I get the current date in a message box?

Use MsgBox Format(Date, "dd-mmm-yyyy") or simply MsgBox Date. The latter will display in the system’s short date format. If you want a custom format, use Format.

Is there a way to get the current date in UTC in VBA?

VBA doesn’t have a built-in UTC function. You can use the Windows API GetSystemTime to retrieve UTC. This requires a Declare statement and a custom Type. For most users, it’s easier to use Now and add the UTC offset manually, but that’s not reliable across time zones. If you need precise UTC, consider using a worksheet formula like NOW() combined with OFFSET or a web service, but that’s beyond typical VBA use.

Remember to Save a Copy Before Running Macros

Before you run any VBA code that writes to cells or changes the workbook, save a copy of the file. Macros cannot be undone with Ctrl+Z. If your code writes the date to a cell and then you close without saving, you might lose data. Always test on a backup.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.