Entering Dates and Times in Excel
In yesterday’s post I showed formulas you can use to pull information from a date in Excel. In some workbooks you’ll enter dates manually, but often you’d like a date to be calculated automatically.
Calculate the Current Date
To show the current date in a cell, use the TODAY function:
=TODAY()
This date will update automatically when you open the workbook on a different date.
Calculate the Current Date and Time
To show the current date and time in a cell, use the NOW function:
=NOW()
This will update automatically.
Manually Enter the Current Date and Time
Instead of formulas, you can enter the date and time as values. These will NOT update automatically.
- To enter the current date in a cell as a value, press the Ctrl key and type a semi-colon (Ctrl+;)
- To enter the current time in a cell as a value, press the Ctrl key and type a colon (Ctrl+Shift+;)
- To enter both the date and time as value, enter the date (Ctrl+;), then a space character, then the time (Ctrl+Shift+;)
Determine When the Workbook Was Last Saved
In yesterday’s post on dates, Mariusz asked how to find the date that the workbook was last saved. Unlike Word, excel doesn’t have a menu command that will insert the last saved date. However, you can use a bit of programming to insert the date, assuming the workbook has been saved.
Sub GetLastSavedDate()
On Error Resume Next
Dim sSaveDate As String
sSaveDate = FileDateTime(ActiveWorkbook.FullName)
If sSaveDate = "" Then
MsgBox "Could not determine save date."
Else
Worksheets("DataEntry").Range("A1").Value _
= "Last Saved: " & sSaveDate
End If
End Sub
Filed under: Excel, Programming, VBA

Comment from Andrew
Time: November 20, 2008, 11:25 am
Wouldn’t it be easier to save the last saved date doing something like this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Worksheets(”DataEntry”).Range(”A1″).Value _
= “Last Saved: ” & Format(Now, “mm/dd/yyyy h:mm AM/PM”)
End Sub
Comment from Debra Dalgleish
Time: November 21, 2008, 9:28 pm
Andrew, yes, that would be a quick way to stamp a file with the save date as you close the workbook.
Using the FileDateTime function, you could open any workbook, and figure out when it was last saved.