Range("A1").Value = Date writes today’s date, Range("A1").Value = Time the current time, and Range("A1").Value = Now both. The values come from the PC’s clock and stay fixed, unlike =TODAY() and =NOW(), which update whenever the sheet recalculates.
To control how the cell shows the value, set its number format and keep the real date underneath: Range("A1").NumberFormat = "yyyy-mm-dd" or "dd mmm yyyy h:mm AM/PM". The value still sorts and calculates as a date.
Use Format when you need text, such as a message or a file name: MsgBox Format(Now, "h:mm AM/PM") or "Report " & Format(Date, "yyyymmdd") & ".xlsx". In a format string, mm straight after h or hh means minutes and anywhere else means the month, so use nn for minutes when in doubt.
Writing a Format result into a cell doesn’t keep the layout. Range("A1").Value = Format(Date, "yyyy/mm/dd") is converted back to a date and shown in a default date format, and Format(Date, "yyyymmdd") becomes the number 20261019. Set NumberFormat instead.
In this tutorial, we will learn different ways to get today’s date and the current time using VBA code.
Today’s Date in VBA
In VBA, there’s a function called “DATE” that you can use to get the current date. When you use this function, as in the following example, it returns the current date according to the system’s date setting.
Sub myMacro() Range("A1") = Date End Sub
When you run this code, it enters the current date into cell A1 and uses the current format of the date that you have in Excel.
Keep in mind that this enters the date as a fixed value. It’s the date when you ran the code, and it doesn’t change tomorrow. If you want a date that updates every time the workbook calculates, enter the TODAY function into the cell instead.
Sub myMacroToday()
Range("A1").Formula = "=TODAY()"
End Sub

You can also use this function to get today’s date into a message box using the following code.
Sub myMacro() MsgBox Date End Sub
Today’s Date and Current Time
In the same way, there’s a function called “NOW” that you can use to get today’s date and the current time. As you can see, we have used it in the following code to get the current date and time into cell A1.

Sub myMacro() Range("A1") = Now End Sub
Current Time
Now, if you want to get only the current time instead of the date and time, you can use another function, “Format”, along with the NOW function.

In this code, we have used the NOW function to provide the value for the FORMAT function and then used a format for the time only.
Sub myMacro() Range("A1") = Format(Now, "HH:MM Am/Pm") End Sub
Here, “HH” is the hour and “MM” is the minutes (when “MM” comes right after the hour, VBA reads it as minutes, not the month). The AM/PM part tells VBA to use the 12-hour clock. If you want a 24-hour time with seconds, use the format “HH:MM:SS” instead.
Sub myMacro24Hour()
Range("A1").Value = Format(Now, "HH:MM:SS")
End Sub
There’s also a simpler way. VBA has a function called “Time” that returns just the current system time, so you don’t need Format at all.
Sub myMacroTime()
Range("A1").Value = Time
MsgBox Time
End Sub
Changing Today’s Date Format (Example: YYYYMMDD)
You can also use the FORMAT function to change the format of the current date. In the following code, we have used the FORMAT function and specified the format as “YYYY/MM/DD”.
Sub myMacro() Range("A1").Value = Format(Date, "YYYY/MM/DD") End Sub
Note: In the above code, we have used the Value property to enter the date into cell A1.

If you want the date without any separator, just like “YYYYMMDD”, remove the slashes from the format. The slash is the date separator, and VBA uses the separator from your system settings, so on some computers you might see a dash or a dot in its place.
Sub myMacroYYYYMMDD()
Range("A1").NumberFormat = "@"
Range("A1").Value = Format(Date, "YYYYMMDD")
End Sub
FORMAT returns text, but when you put that text into a cell, Excel can turn it back into a date or a number, just like when you type it. That’s why the first line sets the cell format to Text, so the result stays exactly as “YYYYMMDD”. If you only want to change how a real date looks, change the cell’s number format instead and keep the value as a date.
Sub myMacroNumberFormat()
Range("A1").Value = Date
Range("A1").NumberFormat = "dd-mmm-yyyy"
End Sub
Get the Day, Month, and Year of Today
You can also get just a part of today’s date. The Day, Month and Year functions return the numbers, and Format with “dddd” returns the full name of the day (like Wednesday).
Sub myMacroDateParts()
MsgBox "Day: " & Day(Date) & vbNewLine & _
"Month: " & Month(Date) & vbNewLine & _
"Year: " & Year(Date) & vbNewLine & _
"Day Name: " & Format(Date, "dddd")
End Sub
Tomorrow’s and Yesterday’s Date
As a date is a number in VBA, you can add or subtract days from it. Date + 1 gives you tomorrow and Date – 1 gives you yesterday. For months or years, use the DateAdd function, which also takes care of month ends.
Sub myMacroNextDates()
Range("A1").Value = Date + 1
Range("A2").Value = Date - 1
Range("A3").Value = DateAdd("m", 1, Date)
End Sub
Frequently Asked Questions
What is the difference between Date and Now in VBA?
Date returns only today’s date, and Now returns today’s date along with the current time. Time returns only the current time.
Why does the cell show #### instead of the date?
The column is too narrow to show the date or time. Make the column wider, or add Range(“A1”).EntireColumn.AutoFit to your code.
Will the date entered by VBA change tomorrow?
No. Date and Now enter a fixed value, like a timestamp. If you need the date to update, enter the TODAY or NOW worksheet function into the cell with the Formula property, as shown at the start of this tutorial.
Written by
Puneet Gogia
Microsoft MVP — Excel · Founder, Excel Champs
Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.