How to Insert the Current Date and Time in Excel – 5 Methods

Method 1 – Using a Shortcut Key to Insert the Current Date and Time

Steps:

  • Select a cell to see the current date and time.

Use Shortcut Key to Insert Current Date and Time

  • Press Ctrl + ; (Semicolon).

The current date will be displayed.

Use Shortcut Key to Insert Current Date and Time

  • Press the Spacebar and again Ctrl + Shift + ; (Semicolon).

The current time will be displayed.

Use Shortcut Key to Insert Current Date and Time

Read More: How to Combine Date and Time in One Cell in Excel


Method 2 – Applying the NOW Function to Insert the Current Date and Time

Steps:

  • Select a cell to see the current date and time.


  • Enter the following formula.
=NOW()

Apply NOW Function to Insert Current Date and Time

  • Press Enter.

You will see the current time and date.

Apply NOW Function to Insert Current Date and Time

  • Date and time will be d automatically updated.

Read More:  How to Auto Update Current Time in Excel 


Method 3 – Running a VBA Code to Insert the Current Date and Time

 

Steps:

  • Click the Developer Tab and select Visual Basic to open VBA Project window. You can also press Alt+F11.

Run a VBA Code to Insert Current Date and Time

  • A new window will open.

  • Enter the following code.
'Code by Aniruddah
Private Sub Worksheet_Change(ByVal Tgt As Range)
On Error GoTo hdlr
If Tgt.Column = 2 And Tgt.Value <> "" Then
Application.EnableEvents = False
Tgt.Offset(0, 1) = Format(Now(), "dd-mm-yyyy hh:mm:ss")
Application.EnableEvents = True
End If
hdlr:
End Sub

  • Close the VB editor.

If you enter data in column B, the adjacent cell in column C will store time and date.

Run a VBA Code to Insert Current Date and Time


Method 4 – Using a Custom Function to Insert the Current Date and Time

Steps:

  • Follow the steps described in Method 3 to open the VB editor.
  • Click Insert and choose Module.

Insert a Custom Function to Insert Current Date and Time

  • Enter the code below into the window.
Function Time_Date_stamp(Reference As Range)
If Reference.Value <> "" Then
Time_Date_stamp = Format(Now, "dd-mm-yyy hh:mm:ss")
Else
Time_Date_stamp = ""
End If
End Function

  • Close the window.
  • In C5, enter the following formula.
=Time_Date_stamp(B5)

Insert a Custom Function to Insert Current Date and Time

  • Press Enter.
  • Drag down the Fill Handle to see the result in the rest of the cells.

Insert a Custom Function to Insert Current Date and Time

If you enter data in B5, C5 will store the day and time.

This is the output.

Insert a Custom Function to Insert Current Date and Time


Method 5 – Use the Power Query to Insert the Current Date and Time

 

  • Go to the Data tab.
  • In Get & Transform Data, select From Table/Range.

  • The Power Editor window will open.
  • In Add Column, select Custom Column.

Use Power Query to Insert Current Date and Time

  • In the new window, enter the New Column Name (Date&Time).
  • In Custom column formula, enter the formula shown below.
=DateTime.LocalNow()
  • Click OK.

Use Power Query to Insert Current Date and Time

A new window will be displayed.

  • Go to the Home tab and click Close & Load To…

Use Power Query to Insert Current Date and Time

  • Select the options shown below.
  • Click OK.

Use Power Query to Insert Current Date and Time

This is the output.

Use Power Query to Insert Current Date and Time

To format the Date&Time column:

  • Go to Number and click the arrow as shown below.

  • Click More Number Formats.

  • In Custom, select the format shown below and click OK.

Use Power Query to Insert Current Date and Time

This is the output.

Use Power Query to Insert Current Date and Time

 


Download Practice Workbook

Download the practice workbook.


Related Articles


<< Go Back to Timestamp | Date-Time in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Aniruddah Alam
Aniruddah Alam

Md. Aniruddah Alam, a graduate of Bangladesh University of Engineering & Technology, Dhaka, holds a BSc.Engg in Naval Architecture & Marine Engineering. Joining Softeko in August 2022 as an Excel and VBA content developer, he has authored 90+ articles, covering fundamental to advanced Excel topics. He actively develops VBA codes for Excel automation and offers solutions in the Exceldemy Forum. Beyond work, he finds leisure in reading books, and taking relaxing walks, showcasing well-rounded blend of professional and... Read Full Bio

2 Comments
  1. Great!
    I was seriously thinking that how will I set a time for my Data Entry and tried many ways but you solved my problem.

    Thanks a lot,
    Akash

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo