Date and timestamp in excel


  • — By
    Sumit Bansal

A timestamp is something you use when you want to track activities.

For example, you may want to track activities such as when was a particular expense incurred, what time did the sale invoice was created, when was the data entry done in a cell, when was the report last updated, etc.

Let’s get started.

Keyboard Shortcut to Insert Date and Timestamp in Excel

If you have to insert the date and timestamp in a few cells in Excel, doing it manually could be faster and more efficient.

Here is the keyboard shortcut to quickly enter the current Date in Excel:

Control + : (hold the control key and press the colon key).

Here is how to use it:

  • Select the cell where you want to insert the timestamp.
  • Use the keyboard shortcut Control + :
    • This would instantly insert the current date in the cell.

Automatically insert Timestamp in Excel - Keyboard shortcut

A couple of important things to know:

  • This shortcut would only insert the current date and not the time.
  • It comes in handy when you want to selectively enter the current date.
  • It picks the current date from your system’s clock.
  • Once you have the date in the cell, you can apply any date format to it. Simply go to the ‘Number Format’ drop-down in the ribbon and select the date format you want.

Note that this is not dynamic, which means that it will not refresh and change the next time you open the workbook. Once inserted, it remains as a static value in the cell.

While this shortcut does not insert the timestamp, you can use the following shortcut to do this:

Control + Shift + :

This would instantly insert the current time in the cell.

Automatically insert date and Timestamp in Excel - shift-control-colon

So if you want to have both date and timestamp, you can use two different cells, one for date and one for the timestamp.

Using TODAY and NOW Functions to Insert Date and Timestamps in Excel

In the above method using shortcuts, the date and timestamp inserted are static values and don’t update with the change in date and time.

If you want to update the current date and time every time a change is done in the workbook, you need to use Excel functions.

This could be the case when you have a report and you want the printed copy to reflect the last update time.

Insert Current Date Using TODAY Function

To insert the current date, simply enter =TODAY() in the cell where you want it.

Automatically insert Timestamp in Excel - Using Today Function

Since all the dates and times are stored as numbers in Excel, make sure that the cell is formatted to display the result of the TODAY function in the date format.

To do this:

Note that this formula is volatile and would recalculate every time there is a change in the workbook.

Insert Date and Timestamp Using NOW Function

If you want the date and timestamp together in a cell, you can use the NOW function.

Automatically insert date and Timestamp in Excel - now function

Again, since all the dates and times are stored as numbers in Excel, it is important to make sure that the cell is formatted to have the result of the NOW function displayed in the format that shows the date as well as time.

To do this:

  • Right-click on the cell and select ‘Format cells’.
  • In the Format Cells dialog box, select ‘Custom’ category in the Number tab.
  • In the Type field, enter dd-mm-yyyy hh:mm:ssinsert-date-and-timestamp-in-excel-custom-format
  • Click OK.

This would ensure that the result shows the date as well as the time.

Note that this formula is volatile and would recalculate every time there is a change in the workbook.

Circular References Trick to Automatically Insert Date and Timestamp in Excel

One of my readers Jim Meyer reached out to me with the below query.

“Is there a way we can automatically Insert Date and Time Stamp in Excel when a data entry is made, such that it does not change every time there is a change or the workbook is saved and opened?”

This can be done using the keyboard shortcuts (as shown above in the tutorial). However, it is not automatic. With shortcuts, you’ll have to manually insert the date and timestamp in Excel.

To automatically insert the timestamp, there is a smart technique using circular references (thanks to Chandoo for this wonderful technique).

Let’s first understand what a circular reference means in Excel.

Suppose you have a value 1 in cell A1 and 2 in cell A2.

Now if you use the formula =A1+A2+A3 in cell A3, it will lead to a circular reference error. You may also see a prompt as shown below:

circular reference prompt in Excel

This happens as you are using the cell reference A3 in the calculation that is happening in A3.

Now, when a circular reference error happens, there is a non-ending loop that starts and would have led to a stalled Excel program. But the smart folks in the Excel development team made sure that when a circular reference is found, it is not calculated and the non-ending loop disaster is averted.

However, there is a mechanism where we can force Excel to at least try for a given number of times before giving up.

Now let’s see how we can use this to automatically get a date and timestamp in Excel (as shown below).

inserting the date and time automatically using circular reference

Note that as soon as I enter something in cells in column A, a timestamp appears in the adjacent cell in column B. However, if I change a value anywhere else, nothing happens.

Here are the steps to get this done:

That’s it!

Now when you enter anything in column A, a timestamp would automatically appear in column B in the cell adjacent to it.

insert-date-and-timestamp-in-excel-timestamp-demo

With the above formula, once the timestamp is inserted, it doesn’t update when you change the contents of the adjacent cell.

If you want the timestamp to update every time the adjacent cell in Column A is updated, use the below formula (use Control + Shift + Enter instead of the Enter key):

=IF(A2<>"",IF(AND(B2<>"",CELL("address")=ADDRESS(ROW(A2),COLUMN(A2))),NOW(),IF(CELL("address")<>ADDRESS(ROW(A2),COLUMN(A2)),B2,NOW())),"")

insert-date-and-timestamp-in-excel-timestamp-update-demo

This formula uses the CELL function to get the reference of the last edited cell, and if it’s the same as the one to the left of it, it updates the timestamp.

Note: When you enable iterative calculations in the workbook once, it will be active until you turn it off. To turn it off, you need to go to Excel Options and uncheck the ‘Enable iterative calculation’ option.

Using VBA to Automatically Insert Timestamp in Excel

If VBA is your weapon of choice, you’ll find it to be a handy way to insert a timestamp in Excel.

VBA gives you a lot of flexibility in assigning conditions in which you want the timestamp to appear.

Below is a code that will insert a timestamp in column B whenever there is any entry/change in the cells in Column A.

'Code by Sumit Bansal from https://trumpexcel.com
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Handler
If Target.Column = 1 And Target.Value <> "" Then
Application.EnableEvents = False
Target.Offset(0, 1) = Format(Now(), "dd-mm-yyyy hh:mm:ss")
Application.EnableEvents = True
End If
Handler:
End Sub

This code uses the IF Then construct to check whether the cell that is being edited is in column A. If this is the case, then it inserts the timestamp in the adjacent cell in column B.

Note that this code would overwrite any existing contents of the cells in column B. If you want. You can modify the code to add a message box to show a prompt in case there is any existing content.

Where to Put this Code?

This code needs to be entered as the worksheet change event so that it gets triggered whenever there is a change.

To do this:

Make sure you save the file with .XLS or .XLSM extension as it contains a macro.

Creating a Custom Function to Insert Timestamp

Creating a custom function is a really smart way of inserting a timestamp in Excel.

It combines the power of VBA with functions, and you can use it like any other worksheet function.

Here is the code that will create a custom “Timestamp” function in Excel:

'Code by Sumit Bansal from http://trumpexcel.com
Function Timestamp(Reference As Range)
If Reference.Value <> "" Then
Timestamp = Format(Now, "dd-mm-yyy hh:mm:ss")
Else
Timestamp = ""
End If
End Function

Where to Put this Code?

This code needs to be placed in a module in the VB Editor. Once you do that, the Timestamp function becomes available in the worksheet (just like any other regular function).

Here are the steps to place this code in a module:

Now you can use the function in the worksheet. It will evaluate the cell to its left and insert the timestamp accordingly.

insert-date-and-timestamp-in-excel-timestamp-formula

It also updates the timestamp whenever the entry is updated.

Make sure you save the file with .XLS or .XLSM extension as it contains VB code.

Hope you’ve found this tutorial useful.

Let me know your thoughts in the comments section.

You May Also Like the Following Excel Tutorials and Resources:

  • How to Run a Macro in Excel.
  • How to Create and Use an Excel Add-ins.
  • Select Multiple Items from a Drop Down List in Excel.
  • Inserting Date and Timestamp in Google Sheets.
  • A Collection of FREE Excel Templates.
  • Excel Timesheet Template.
  • Excel Calendar Template.
  • Convert Time to Decimal Number in Excel (Hours, Minutes, Seconds)
  • How to Autofill Only Weekday Dates in Excel (Formula)
  • Make VBA Code Pause or Delay (Using Sleep / Wait Commands)

Excel Ebook Subscribe

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

61 thoughts on “How to Quickly Insert Date and Timestamp in Excel”

  1. so amazing

  2. All of this is very clever and I even got it all to work using VBA to insert a time in a column to the right of where I entered some data. Perfect but .. How can you protect your code, as you can see it and edit it by doing View Code, even if the sheet and/or workbook is protected? Also when I saved it and then re-opened the worksheet it stopped working – what have I done wrong? Wonderful stuff!! Thank you.

  3. Thank you awesome work i know its hard to get these formulas running how you like and i just wanted to thank you for letting people like me steal them off the web 🙂

  4. Doesn’t work in Online Excel ?

  5. What if I want to check a range of cells B2 – G2 and if any are updated, update the date and timestamp?

  6. Thank you for all the instructions, I used this option

    =IF(A2″”,IF(AND(B2″”,CELL(“address”)=ADDRESS(ROW(A2),COLUMN(A2))),NOW(),IF(CELL(“address”)ADDRESS(ROW(A2),COLUMN(A2)),B2,NOW())),””)

    Works fine, but after keeping the sheet open for a few hours, while updating it, the timestamp gives an #N/A error and can’t get it back.

    I use the VBA timestamp function to get over this, seems to be working fine…

    Any ideas?

    Thank you

  7. For Timestamp Update Formula:

    =IF(B4″”,IF(AND(F4″”,CELL(“address”)=ADDRESS(ROW(B4),COLUMN(F4))),NOW(),IF(CELL(“address”)ADDRESS(ROW(B4),COLUMN(B4)),F4,NOW())),””)

    Works fine when it is on the same sheet, but its not working for different sheet even after changing the reference all B4 into Sheet1!B4 and looking output in the Sheet 2 in F4 Cell

  8. This has worked perfect for what I was trying to create. I now have the problem of the timestamp resetting each time I reopen the file. Is there a way for the timestamp to stay the same from when the data was put in?

    • Disregard…

  9. Hi

    I need a timestamp on “C” that updates the time when either “A” or “B” is updated. I can’t use a macro as I need my file in Sharepoint and to be accessible by many people at the same time.

    How can I use the circular reference or the Custom Function for this purpose?

    Thanks!

  10. it working fine with me, however i have issue when using auto-filter or Auto-clear-filter function for designated table, it will keep updating the timestamp in all timestamp reference cells…

    below sub :
    ——————————————————————–
    Sub Access_Filter()

    Dim WeekS As String
    Dim WeekE As String

    WeekS = “>=” & Application.InputBox(Prompt:=”Enter Start Date”, Default:=Format(Date, “dd mmm yyyy”), Type:=2)
    WeekE = “<=» & Application.InputBox(Prompt:=»Enter End Date», Default:=Format(Date, «dd mmm yyyy»), Type:=2)

    ActiveSheet.ListObjects(«ACCESS»).Range.AutoFilter Field:=3, Criteria1:=WeekS, Operator:=xlAnd, Criteria2:=WeekE

    End Sub
    ———————————————————————————-
    Sub Access_Clear_All_Filters_Range()

    ‘To Clear All Fitlers use the ShowAllData method for
    ‘for the sheet. Add error handling to bypass error if
    ‘no filters are applied. Does not work for Tables.
    On Error Resume Next
    ActiveSheet.ListObjects(«ACCESS»).Range.AutoFilter Field:=3
    On Error GoTo 0
    ActiveSheet.ListObjects(«ACCESS»).Range.End(xlDown).Select

    End Sub

    • I am having this issue too. I am using it in a table and every time i change filters, it updates to the current time.

  11. Great job thanks!

  12. How to put an start date and time with end date and time? Same as above with duration.

  13. Hi guys, I tried to apply the formula below. It works and i saved my macro excel. But when I opened my file (1st time after the file created) the macro was put to disable. when i enable it then the timestamp reset. It also happened when the file was opened from other user which using the same network folder. any idea how to prevent the timestamp reset?

    Function Timestamp(Reference As Range)
    If Reference.Value “” Then
    Timestamp = Format(Now, “dd-mm-yyy hh:mm:ss”)
    Else
    Timestamp = “”
    End If
    End Function

    • Same issue not sure if anyone found a solution.

  14. For the formula
    =IF(A2″”,IF(AND(B2″”,CELL(“address”)=ADDRESS(ROW(A2),COLUMN(A2))),NOW(),IF(CELL(“address”)ADDRESS(ROW(A2),COLUMN(A2)),B2,NOW())),””)

    is it possible to change “A2” to a range of cells?

    • I agree is it possible to add a list of cells that are changed and record the dates the they were changed??

  15. For the formula
    =IF(A2″”,IF(AND(B2″”,CELL(“address”)=ADDRESS(ROW(A2),COLUMN(A2))),NOW(),IF(CELL(“address”)ADDRESS(ROW(A2),COLUMN(A2)),B2,NOW())),””)

    is it possible to change “A2” to a range of cells?
    I would like to use “A2:M2” as the affected cells, so the timestamp updates when any one of that range of cells is modified. I tried to change it but it would not work.
    I added another set of parentheses to each A2:M2 range, still no luck.

    • H i Ron, I had the same problem and fixed it by adding an OR within the AND expression like:

      In an example field C2 is also ‘monitored’ for change.
      It is a formula mess but it works.

      =IF(A2″”,IF(AND(B2″”,OR(CELL(“address”)=ADDRESS(ROW(A2),COLUMN(A2)),CELL(“address”)=ADDRESS(ROW(C2),COLUMN(C2)))),NOW(),IF(CELL(“address”)ADDRESS(ROW(A2),COLUMN(A2)),B2,NOW())),””)

  16. Hi Guys i’m looking for something similar the point of difference is as follows … eg There is a column A which is part of a table where it records a series of values based on a formula. values are “text 1″,”text2″ text3” etc . What i want is in column b, should the value in corresponding Acell reaches “text3” then it records the date when the cell reached “Text 3” else blank. Can anyone help…

  17. excellent!

  18. Hi, Sumit.Greetings!!
    I’m preparing a worksheet to enter all the received purchase orders & associated details viz. customer name, item type, item drawing no., drawing revision no. in po, etc. Say BOOK1
    When all the relevant data is entered then I get ” found-clear” in column O & now all the data related to that entry is to be extracted to another book, say BOOK-2.
    Also extracted data should appear in BOOK-2 in a sequential manner, without blank rows & as any entry is cleared in BOOK-1(PO entry workbook), it should appear in BOOK-2 below all the previously extracted entries.

    To solve this, I thought of getting :
    1) Fixed, non-volatile timestamps as soon as ” found-clear” appears in column O for any PO entry.
    2) To give Rank to these timestamps, using Rank Function.
    3) Then use Index, Match, Rows to extract data in a sequential sorted manner.

    To get fixed( non-volatile) timestamps I applied two approaches as shown by you:
    1) Circular reference with NOW()
    2) UDF

    I’ve attached an excel file with two sheets:
    1) Examples
    2) Application

    Problem 1) with circular reference & NOW()

    1A) Also if I change conditions so that “found-clear” is removed & then recreate the conditions to get “found-clear” back, timestamp disappears.

    Problem 2) with UDF; refer sheet” examples”, SAMPLE-3
    2A) It is showing the year as 1989 in place of 2019.
    2B) If I make any changes to the worksheet, like add or remove cells anywhere in the worksheet, all the timestamps change to current time & date.
    2C) Rank function not working.

  19. Guys,

    I have a different requirement and this is for stock market.

    Let us say I have Columns A to G in the excel sheet and the columns heading reading as below for stock market :

    Symbol, Lot Size, Open, High, Low, LTP and the Signal Column (which gives Buy or Sell based on a strategy).

    The last column which is the Signal Column (and which happens to be Column G) contains the “Buy”or “Sell” or Ëmpty when there is no signal. This column is dynamic, in the sense, as and when the data across A-F changes, I get new signals like Buy or Sell or Empty, depending upon the strategy.

    My expectation is, as and when I get a Buy or a Sell or an empty in Column G (in the event of a Buy and Sell that has changed to an empty cell), I want to timestamp, let us say, Column H with the exact time the change happened (regardless of Buy or Sell or empty (post a buy or sell). And this timestamp should not change the time, unless any change happens in Column G. For e.g. a buy changing to a sell or a sell changing to a buy or a buy/sell changing to an empty cell.

    Let me know if the above explanation helps.

    • The challenge I have with the available solution on the net is, my Excel sheet refreshes every 1 minute pulling data off the net, and as and when it does, the timestamp changes to the current time as against the time the signal came.
      For e.g. a BUY or SELL that came at say 11:15 AM, should remain static unless the signal changes from a buy to sell or a sell to buy, but everytime my excel refreshes it updates with the current time in this column. What I am looking for is to understand what time a buy or sell came.

  20. I used this formula yesterday on 5th March and it worked perfect =IF(A2″”,IF(B2″”,B2,NOW()),””) my dates registered as 5th March timestamp. However I’ve now come into the same spreadsheet the very next day on 6th March but when i enter data into column A new rows, the formula in column B remains blank no result. Is there another step I’ve missed so it recognises a new day?

  21. Super easy directions – thankyou 🙂

  22. This has been really helpful! thank you! I was wondering if we’re able to input in multiple cells (e.g. A2, B2, D2) and still get and updated timestamp in “F2” when ever the multiple cells (A2, B2, D2) are updated.

  23. It worked on one Excel Spreadsheet but when I tried it again on another Spreadsheet (totally different workbook), it just shows a blank cell. I have it formatted for date.

  24. In the example, “Using VBA to Automatically Insert Timestamp in Excel” I have a condition where a process is running and I want to ‘time stamp’ when it began in one column and ‘time stamp’ (date and time) when the process ended, a few columns to the right…meaning a start and stop time stamp. Can this formula accommodate this requirement?

  25. Hi,

    Thanks Sumit, very nice contribution 🙂

    To add to your article for those, who like to have a static value for Date or Time Stamp and need a specific date / time format but without going through VBA, you may consider this option:

    1. Choose one Reference Cell, e.g. [A1]. It can be on a separate worksheet.

    Put in the formula
    =today()
    or
    =now()

    2. Give that cell the name “Time” or “Date”

    3. Now, if you want to enter current Date or Time in any cell in your workbook, just type

    =Date
    or
    =Time

    The target cell can be formatted according to your preferences, e.g. “YYYY-MM-DD” or “hh:mm:ss”. The advantage is that you can also catch the seconds which is not possible with the keyboard shortcut [CTRL] + [SHIFT] + [:].

    4. You can also incorporate this in any formulas you are using in your worksheet.

    Example:

    Every time you enter the word “ok” in Row [C], Row [B] will automatically register the current time. To do this format Row [B] as “hh:mm:ss”.
    Now, in cell [B1] you enter the formula

    if(C1=”ok”,Time,””)

    Then you copy this formula to the range you will be using.

    Now, every time you enter “ok” in a cell on Row [C], you will get an automatic (and static) time stamp in the adjacent cell in Row [B].

  26. NICE great article style and super helpful

  27. I’m trying to create a timestamp based on a dropdown value, however leveraging the macro is providing a validation error. Is there a workaround? If I use in a blank (no validation field) the vba/macro works correctly.

  28. Function Timestamp(Reference As Range)
    If Reference.Value “” Then
    Timestamp = Format(Now, “dd-mm-yyy hh:mm:ss”)
    Else
    Timestamp = “”
    End If
    End Function

    is not worjking ???

    • there is a typo in the formula,
      replace -yyy by -yyyy (4 letters) and it will work.

  29. Hi there – this is FABULOUS! Really saved me a lot of pain!

    Can you assist with one thing?

    I need to be able to create the timestamp, on a separate row, each time a (custom function) button is pressed?

    We will be using this to create a basic “footfall counter” to count the time/date and number of people passing into our IT support area.

    If you can assist, this would be amazing…

  30. Thank you for your tips! I am an italian Excel Professionist and often i read your blog. Good work 😉 Marck

  31. Is it possible to write a code that take effect of Cell A or Cell B for the timestamp?

    using below code:
    Function Timestamp(Reference As Range)
    If Reference.Value <> “” Then
    Timestamp = Format(Now, “dd-mm-yyy hh:mm:ss”)
    Else
    Timestamp = “”
    End If
    End Function

    In cell C, should I use =timestamp(A1:B2)

  32. This is just what I needed. You rock!
    Thank you!

  33. =IF($A12<>“”,IF(AND($I12<>“”,CELL(“address”)=ADDRESS(ROW($A12),COLUMN($A12))),NOW(),IF(CELL(“address”)<>ADDRESS(ROW($A12),COLUMN($A12)),$I12,NOW())),””)

    i CHECKED FOR ITERATION ALSO.. EVEN ITS NOT WORKING KINDLY HELP ON THIS

  34. NOT WORKING SECOND FORMULA

  35. I use the following formula (=IF(A2″”,IF(B2″”,B2,NOW()),””)
    But whenever i type in other cells, the time updated.
    or when i save and close, then reopen the date and time updated automatically.

  36. Superb Job.Thanks

  37. Can the custom function be modified to display hh:mm then am or pm?

  38. Wowww This is what I am looking for!!!

    THANK YOU SO MUCHHH!!!!

  39. One issue: keeping the formula options for iterations to prevent the cirucular reference error. The options are not saved with the sheet. They are saved on the computer and those saved options change with each workbook you open. For a timestamp with a circular reference you need to set the options as the workbook opens. Use this macro:

    Private Sub Workbook_Open()
    Application.Calculation = xlCalculationAutomatic
    Application.Iteration = True
    Application.MaxIterations = 1
    End Sub

    That solves the problem and the formula works fine every time.

  40. Why =IF($A$1″”,NOW()) does not work here.

  41. grate! just you should say that it works mailny or totaly only on ENG versions.
    I have Excel in italian and many of this stuff does not work like that

  42. I have checked ‘enable iterative calculation’ option and I have put the formula =IF(A2””,IF(B2””,B2,NOW()),””) in cell B2 but I am getting error #Name? when I enter any text in A2.

    • Hello Sajid.. Your double quotes are not in the right format (it happens sometimes when copied directly from the webpage). Just delete the double quotes and enter it manually. It would work then.

      • Yes, Now it’s working. Thank you so much Sumit.

  43. I like the automated timestamp, I have users who have asked for similar things, it gives ideas on how to implement.

  44. Thanks Sumit……..I was searching this for more over decade.

    • Glad you found this useful Anand!

  45. When I tried to use the formulas to insert the timestamp, it returned 1/0/1900. It sounds like some setting that needs to changed but I couldn’t figure out where or what to change.

    • Hello Terry.. You need to check the ‘enable iterative calculation’ option for this to work

      • How to make it work for an online excel sheet shared with multiple people?

  46. Good one! thanks

    • Thanks Ashesh!

  47. Excellent tip! Thank you!

    • Thanks for commenting.. Glad you liked it 🙂

Comments are closed.

The Date and Timestamp is a type of data type that determines the date and time of a particular region. It contains some characters along with some encoded data. This format may vary from language to language. Keeping track of date and time helps in managing records of our work as well as segregate the information day-wise. In this article, we will be going to learn how we can automatically insert Date and Timestamp in Excel.

There are multiple ways to insert Date and Timestamp in Excel. These methods include both static and dynamic methods.

1. Inserting Date And Timestamp using keyboard shortcuts (Static method)

The static method is helpful when there are only a few cells where you need to insert the Date and Timestamp. You can quickly use the keyboard shortcut to manually insert the Date and Timestamp.

Follow the below steps to implement the same:

  • Select the cell into which the current date or time needs to be inserted.
  • Use this shortcut – Ctrl + ; (Control + semicolon) to insert the current date.
  • Use this shortcut – Ctrl + Shift + ; (Control + Shift + semicolon) to insert the current time.
  • Use this shortcut – Press the combination (Ctrl + ;) and (Ctrl + Shift + ;) to insert the current time and time.

2. Inserting Date And Timestamp using  Formulas:

The NOW() and TODAY() functions can be used to insert the current date and time that will update automatically. This method dynamically updates the date-time whenever a change is made in the worksheet.

  1. NOW(): To insert current date and time.
  2. TODAY(): To insert the current date.

Follow the below steps to implement the same:

  • Select the cell into which the current date or time needs to be inserted.
  • Enter the function NOW() or TODAY().
  • Press the Enter key.
  • The current date-time or date will be inserted into the selected cell.

3. Insert Timestamp Automatically While Entering Data In Different Column

This method will enable the insertion of the timestamp in a column while entering data into another column. For example, consider two columns A and B in your worksheet. While you enter data in a cell of column A, the current date and time in the corresponding cell in Column B will get updated automatically.

Follow the below steps to implement the same:

  • Click File -> Options and the Excel Options dialogue box will appear. Now from the left pane, select the Formulas option. You will see Enable interactive calculation in the right pane below Calculation options. Check this option and select OK.

  • In this next adjoining column (say column B), enter this formula: 
=IF(A1<>"",IF(B1<>"",B1,NOW()),"")
  • Drag and select cells to auto-fill the formula.

  • You can also customize the format of the date and time. To do this, right-click on the selected formula cells, go to the context menu, and select Format Cells. You will see the Format cells dialogue box. Go to the bottom and select Custom. In the right pane select the suitable format for your cells.

  • Now when you enter the data in a column, you will get the date and time in your chosen format in the adjoining cell.

4. Using VBA To Insert Timestamp Automatically While Entering Data In a Different Column

If you are familiar with working on VBA, then there is another method for you to automatically insert the timestamp in your excel sheet using VBA.

Follow the below steps to implement the same:

  • To open Microsoft Visual Basic for Applications, press Alt + F11. The VBA window will open. Now go to Insert and select the Module to open a blank module.

  • Now, add the code given below to your blank module and save the code.
Function MyTimestamp(Reference As Range)

If Reference.Value <> "" Then

MyTimestamp = Format(Now, "dd-mm-yyyy hh:mm:ss")

Else

MyTimestamp = ""

End If

End Function

  • Go back to your worksheet and type the below formula in your cell in which you want to insert timestamp.
A is the column for inserting entries of data.
B is corresponding column, into which the date and timestamp will be updated.

Type the below formula into B1 cell:
=MyTimestamp(A1)

  • Now, if you insert the entry in a column, you will get the date and time in the adjoining cell automatically.

Unix timestamp is also called Epoch time or POSIX time which is wildly used in many operating systems or file formats. This tutorial is talking about the conversion between date and Unix timestamp in Excel.

Convert date to timestamp

Convert date and time to timestamp

Convert timestamp to date

More tutorials about datetime conversion…


arrow blue right bubble Convert date to timestamp

To convert date to timestamp, a formula can work it out.

Select a blank cell, suppose Cell C2, and type this formula =(C2-DATE(1970,1,1))*86400 into it and press Enter key, if you need, you can apply a range with this formula by dragging the autofill handle. Now a range of date cells have been converted to Unix timestamps.
doc-convert-date-unix-1


doc converttime 1


arrow blue right bubble Convert date and time to timestamp

There is a formula that can help you convert date and time to Unix timestamp.

1. Firstly, you need to type the Coordinated Universal Time into a cell, 1/1/1970. See screenshot:
doc-convert-date-unix-2

2. Then type this formula =(A1-$C$1)*86400 into a cell, press Enter key, then if you need, drag the autofill handle to a range with this formula. See screenshot:
doc-convert-date-unix-3

Tips: In the formula, A1 is the date and time cell, C1 is the coordinate universal time you typed.


arrow blue right bubble Convert timestamp to date

If you have a list of timestamp needed to convert to date, you can do as below steps:

1. In a blank cell next to your timestamp list and type this formula =(((A1/60)/60)/24)+DATE(1970,1,1), press Enter key, then drag the auto fill handle to a range you need.
doc-convert-date-unix-4

2. Then right click the cells used the formula, and select Format Cells from the context menu, then in the popping Format Cells dialog, under Number tab, click Date in the Category list, then select the date type in the right section.
doc-convert-date-unix-5

3. Click OK, now you can see the Unix timestamps have been converted to dates.
doc-convert-date-unix-6

Notes:

1. A1 indicates the timestamp cell you need.

2. This formula also can use to convert timestamp series to date and time, just format the result to the date and time format.

3. The above formula converts 10-digits number to a standard datetime, if you want to convert 11-digits number, or 13-digits number, or 16-digits number to a standard datetime in Excel, please use formula as below:

Convert 11-digits number to date: =A1/864000+DATE(1970,1,1)

Convert 13-digits number to date: =A1/86400000+DATE(1970,1,1)

Convert 16-digits number to date: =A1/86400000000+DATE(1970,1,1)

For different lengths of number which needed to be converted to datetime, just change the number of zeros of the divisor in the formula to correctly get the result.


Relative Articles:

  • How to convert date time from one time zone to another in Excel?
    This article will show you how to convert date time from one time zone to another in Excel.

  • How to split date and time from a cell to two separated cells in Excel?
    For instance, you have a list of data mixed with date and time, and you want to split each of them into two cells, one is date and another is time as below screenshots shown. Now this article provides you two quick methods to solve it in Excel.

  • How to convert date/time format cell to date only in Excel?
    If you want to convert date-time format cell to date value only such as 2016/4/7 1:01 AM to 2016/4/7, this article can help you.

  • How to remove time from date in Excel?
    If there has a column of date with time stamp, such as 2/17/2012 12:23, and you don’t want to retain the time stamp and want to remove the time 12:23 from the date and only leave the date 2/17/2012. How could you quickly remove time from date in mulitple cells in Excel?

  • How to combine date and time into one cell in Excel?
    There are two columns in a worksheet, one is the date, the other is time. Is there any way to quickly combine these two columns into one, and keep the time format? Now, This article introduces two ways in Excel to combine date column and time column into one and keep the time format.


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails…
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns… Prevent Duplicate Cells; Compare Ranges
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select…
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more…
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic…
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF
  • More than 300 powerful features. Supports Office / Excel 2007-2021 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.

kte tab 201905


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

officetab bottom

Содержание

  1. Convert Unix time stamp to Excel date
  2. Related functions
  3. Summary
  4. Generic formula
  5. Explanation
  6. How Excel tracks dates time
  7. Русские Блоги
  8. Как преобразовать дату и метку времени Unix в Excel?
  9. Просмотр и редактирование с вкладками нескольких книг Excel / документов Word, таких как Firefox, Chrome, Интернет 10!
  10. How to Quickly Insert Date and Timestamp in Excel
  11. Keyboard Shortcut to Insert Date and Timestamp in Excel
  12. Using TODAY and NOW Functions to Insert Date and Timestamps in Excel
  13. Insert Current Date Using TODAY Function
  14. Insert Date and Timestamp Using NOW Function
  15. Circular References Trick to Automatically Insert Date and Timestamp in Excel
  16. Using VBA to Automatically Insert Timestamp in Excel
  17. Creating a Custom Function to Insert Timestamp

Convert Unix time stamp to Excel date

Summary

To convert a Unix timestamp to Excel’s date format, you can use a formula based on the DATE function. In the example shown, the formula in C5 is:

Generic formula

Explanation

The Unix time stamp tracks time as a running count of seconds. The count begins at the «Unix Epoch» on January 1st, 1970, so a Unix time stamp is simply the total seconds between any given date and the Unix Epoch. Since a day contains 86400 seconds (24 hours x 60 minutes x 60 seconds), conversion to Excel time can be done by dividing days by 86400 and adding the date value for January 1st, 1970.

In the example shown, the formula first divides the time stamp value in B5 by 86400, then adds the date value for the Unix Epoch, January 1, 1970. The formula evaluates like this:

When C5 is formatted with the Excel date «d-mmm-yyyy», the date is displayed as 1-Oct-2018.

How Excel tracks dates time

The Excel date system starts on January 1, 1900 and counts forward. The table below shows the numeric values associated with a few random dates:

Date Raw value
1-Jan-1900 1
28-Jul-1914 00:00 5323
1-Jan-1970 00:00 25569
31-Dec-1999 36525
1-Oct-2018 43374
1-Oct-2018 12:00 PM 43374.5

Notice the last date includes a time as well. Since one day equals 1, and one day equals 24 hours, time in Excel can represented as fractional values of 1, as shown in the table below. In order to see the value displayed as a time, a time format needs to be applied.

Источник

Русские Блоги

Как преобразовать дату и метку времени Unix в Excel?

Временная метка Unix также называется временем эпохи или временем POSIX, которое широко используется во многих операционных системах или форматах файлов. В этом руководстве обсуждается преобразование даты в метку времени Unix в Excel.

Преобразовать дату в метку времени

Просмотр и редактирование с вкладками нескольких книг Excel / документов Word, таких как Firefox, Chrome, Интернет 10!

Возможно, вы знакомы с просмотром нескольких веб-страниц в Firefox / Chrome / IE и можете переключаться между ними, легко щелкая соответствующую вкладку. Здесь вкладка Office поддерживает аналогичную обработку, позволяя просматривать несколько книг Excel или документов Word в одном окне Excel или Word и легко переключаться между ними, щелкая вкладку. ЧтобыНажмите на бесплатную 45-дневную пробную версию Office Tab!

Чтобы преобразовать дату в метку времени, вы можете использовать формулу для решения проблемы.

Выберите пустую ячейку и введите эту формулу = (A1-DATE (1970,1,1)) * 86400 Enter и нажмитевойтиKey, при необходимости, вы можете применить диапазон этой формулы, перетащив маркер автозаполнения. Теперь ряд ячеек даты преобразован в отметки времени Unix.

Преобразование даты и времени в метку времени

Существует формула, которая поможет вам преобразовать дату и время в метку времени Unix.

1. Во-первых, вам нужно ввести всемирное координированное время в ячейку 01.01.1970. Смотрите скриншот:

2. Затем введите эту формулу = (A1- $ C $ 1) * 86400 в ячейку, нажмитеВойтиKey и при необходимости используйте эту формулу, чтобы перетащить дескриптор автозаполнения в диапазон. Смотрите скриншот:

подсказки: В формуле A1 — это ячейка даты и времени, а C1 — введенная вами координата мирового времени.

Преобразовать метку времени на дату

Если у вас есть список меток времени, которые необходимо преобразовать в даты, вы можете выполнить следующие действия:

1. В пустой ячейке рядом со списком отметок времени введите эту формулу = (((A1 / 60) / 60) / 24) + ДАТА (1970,1,1), нажмитевойтиButton, а затем перетащите маркер автозаполнения в нужный диапазон.

2. Затем щелкните правой кнопкой мыши ячейку, в которой используется формула, и выберитеФормат ячейкиИз контекстного меню, а затем во всплывающемФормат ячейкиДиалоговое окно под NУмбраЯрлык, щелкнитеДатаВкатегорияСписок, а затем выберите тип даты справа.

3. НажмитеOK, Теперь вы можете видеть, что метка времени Unix была преобразована в дату.

незамедлительный:

1. A1 представляет нужную ячейку с отметкой времени.

2. Эту формулу также можно использовать для преобразования серии отметок времени в дату и время, просто отформатируйте результат в формате даты и времени.

Быстро и легко конвертируйте даты в другие форматы дат в Excel

Источник

How to Quickly Insert Date and Timestamp in Excel

A timestamp is something you use when you want to track activities.

For example, you may want to track activities such as when was a particular expense incurred, what time did the sale invoice was created, when was the data entry done in a cell, when was the report last updated, etc.

This Tutorial Covers:

Let’s get started.

Keyboard Shortcut to Insert Date and Timestamp in Excel

If you have to insert the date and timestamp in a few cells in Excel, doing it manually could be faster and more efficient.

Here is the keyboard shortcut to quickly enter the current Date in Excel:

Here is how to use it:

  • Select the cell where you want to insert the timestamp.
  • Use the keyboard shortcut Control + :
    • This would instantly insert the current date in the cell.

A couple of important things to know:

  • This shortcut would only insert the current date and not the time.
  • It comes in handy when you want to selectively enter the current date.
  • It picks the current date from your system’s clock.
  • Once you have the date in the cell, you can apply any date format to it. Simply go to the ‘Number Format’ drop-down in the ribbon and select the date format you want.

Note that this is not dynamic, which means that it will not refresh and change the next time you open the workbook. Once inserted, it remains as a static value in the cell.

While this shortcut does not insert the timestamp, you can use the following shortcut to do this:

This would instantly insert the current time in the cell.

So if you want to have both date and timestamp, you can use two different cells, one for date and one for the timestamp.

Using TODAY and NOW Functions to Insert Date and Timestamps in Excel

In the above method using shortcuts, the date and timestamp inserted are static values and don’t update with the change in date and time.

If you want to update the current date and time every time a change is done in the workbook, you need to use Excel functions.

This could be the case when you have a report and you want the printed copy to reflect the last update time.

Insert Current Date Using TODAY Function

To insert the current date, simply enter =TODAY() in the cell where you want it.

Since all the dates and times are stored as numbers in Excel, make sure that the cell is formatted to display the result of the TODAY function in the date format.

Note that this formula is volatile and would recalculate every time there is a change in the workbook.

Insert Date and Timestamp Using NOW Function

If you want the date and timestamp together in a cell, you can use the NOW function.

Again, since all the dates and times are stored as numbers in Excel, it is important to make sure that the cell is formatted to have the result of the NOW function displayed in the format that shows the date as well as time.

  • Right-click on the cell and select ‘Format cells’.
  • In the Format Cells dialog box, select ‘Custom’ category in the Number tab.
  • In the Type field, enter dd-mm-yyyy hh:mm:ss
  • Click OK.

This would ensure that the result shows the date as well as the time.

Note that this formula is volatile and would recalculate every time there is a change in the workbook.

Circular References Trick to Automatically Insert Date and Timestamp in Excel

One of my readers Jim Meyer reached out to me with the below query.

This can be done using the keyboard shortcuts (as shown above in the tutorial). However, it is not automatic. With shortcuts, you’ll have to manually insert the date and timestamp in Excel.

To automatically insert the timestamp, there is a smart technique using circular references (thanks to Chandoo for this wonderful technique).

Let’s first understand what a circular reference means in Excel.

Suppose you have a value 1 in cell A1 and 2 in cell A2.

Now if you use the formula =A1+A2+A3 in cell A3, it will lead to a circular reference error. You may also see a prompt as shown below:

This happens as you are using the cell reference A3 in the calculation that is happening in A3.

Now, when a circular reference error happens, there is a non-ending loop that starts and would have led to a stalled Excel program. But the smart folks in the Excel development team made sure that when a circular reference is found, it is not calculated and the non-ending loop disaster is averted.

However, there is a mechanism where we can force Excel to at least try for a given number of times before giving up.

Now let’s see how we can use this to automatically get a date and timestamp in Excel (as shown below).

Note that as soon as I enter something in cells in column A, a timestamp appears in the adjacent cell in column B. However, if I change a value anywhere else, nothing happens.

Here are the steps to get this done:

Now when you enter anything in column A, a timestamp would automatically appear in column B in the cell adjacent to it.

With the above formula, once the timestamp is inserted, it doesn’t update when you change the contents of the adjacent cell.

If you want the timestamp to update every time the adjacent cell in Column A is updated, use the below formula (use Control + Shift + Enter instead of the Enter key):

This formula uses the CELL function to get the reference of the last edited cell, and if it’s the same as the one to the left of it, it updates the timestamp.

Note: When you enable iterative calculations in the workbook once, it will be active until you turn it off. To turn it off, you need to go to Excel Options and uncheck the ‘Enable iterative calculation’ option.

Using VBA to Automatically Insert Timestamp in Excel

If VBA is your weapon of choice, you’ll find it to be a handy way to insert a timestamp in Excel.

VBA gives you a lot of flexibility in assigning conditions in which you want the timestamp to appear.

Below is a code that will insert a timestamp in column B whenever there is any entry/change in the cells in Column A.

This code uses the IF Then construct to check whether the cell that is being edited is in column A. If this is the case, then it inserts the timestamp in the adjacent cell in column B.

Note that this code would overwrite any existing contents of the cells in column B. If you want. You can modify the code to add a message box to show a prompt in case there is any existing content.

Where to Put this Code?

This code needs to be entered as the worksheet change event so that it gets triggered whenever there is a change.

Make sure you save the file with .XLS or .XLSM extension as it contains a macro.

Creating a Custom Function to Insert Timestamp

Creating a custom function is a really smart way of inserting a timestamp in Excel.

It combines the power of VBA with functions, and you can use it like any other worksheet function.

Here is the code that will create a custom “Timestamp” function in Excel:

Where to Put this Code?

This code needs to be placed in a module in the VB Editor. Once you do that, the Timestamp function becomes available in the worksheet (just like any other regular function).

Here are the steps to place this code in a module:

Now you can use the function in the worksheet. It will evaluate the cell to its left and insert the timestamp accordingly.

It also updates the timestamp whenever the entry is updated.

Make sure you save the file with .XLS or .XLSM extension as it contains VB code.

Hope you’ve found this tutorial useful.

Let me know your thoughts in the comments section.

You May Also Like the Following Excel Tutorials and Resources:

Источник

Home / Excel Basics / How to Insert a Timestamp in Excel [Formula + VBA + Shortcut]

A few years back when I was working for a tech company I was one of those people who were an Excel help point for all. And that’s the real reason I’m fascinated to learn more. One day the lady who was working as a reception coordinator came to me and asked:

Puneet, I’m managing a list of tasks and I want to add date and time in the corresponding cell on completion of each task. Which is the best way?

And quickly I realized that she was talking about a timestamp. I’m sure you also use it while working in Excel. In general, it contains the current date and time, and we use it to capture the completion time of a task. Now the thing is: Which is the best way to insert a timestamp in Excel?

In this post, you’ll learn how to create a timestamp in Excel using 5 different ways and we will try to figure out which is the best out of all. So let’s get started.

1. Using a Keyboard Shortcut to Insert a Timestamp

There are two different shortcuts to insert a date and a time. And, here we need to use both of them subsequently. Here are the steps:

insert a timestamp in excel using a shortcut key
  1. First of all, select the cell where you need to insert a timestamp.
  2. After that, use the shortcut key Control + : (Press and hold control and then press colon). Once you press this, it will insert the current date (according to your system) in the cell.
  3. At this time, your cell is in edit mode.
  4. Now, press Control + Shift + : (Press and hold the control and shift key and then press the colon).
  5. Your cell is still in edit mode, now press the enter key to complete the entry.

In short, you need to press two shortcuts in sequence to insert this. And, if you want to add only one thing of date and time, just skip the shortcut key.

PROs Cons
If you want to save time and have fewer cells, this method is perfect. This is not a dynamic method, you have a static timestamp. And if you want to update the time stamp you need to enter it again.
When you enter both the date and time, Excel automatically picks the right format to display it. You need to press two different shortcut keys to enter it.

2. Insert a Timestamp with NOW Function

A simple dynamic method. If you want to use a formula to insert a timestamp, the perfect way is to use the NOW function. When you enter this function in a cell it returns the current date and time according to your system’s settings.

The default format of date and time return by NOW is mm/dd/yyyy hh:mm. But for some reason, if you want a custom format, you change its format using the custom format option. Select the cell ➜ Press shortcut key control + 1 ➜ Select “Custom” ➜ Enter “mm/dd/yyyy hh:mm” in the input box ➜ Click OK.

And if you want to enter the only date then you can use TODAY instead of NOW, it only returns the current date according to the system’s settings.

insert a timestamp in excel with today

Pros

  1. It’s a dynamic method.
  2. You can use both of the functions with an IF function to create a condition to enter a timestamp if another cell has a value.

Cons

  1. Even though it’s a dynamic method but as both of the functions are volatile they will get updated whenever you make changes to your worksheet.
  2. And if you just want values instead of formulas you need to convert them into values manually.

3. Using Circular Reference for Creating a Timestamp

If you want to get into an advanced method and don’t want to use methods #1 and #2 then you can use a circular reference to insert a timestamp.

But before you learn this method let’s understand what circular reference is all about. Let’s say you have a value of 5 in cell A1 and a value of 10 in cell B1. Now if you enter a formula =A1+B1+C1 in cell C1, it will return a message circular reference error.

insert a timestamp in excel with circular reference

This is because you are using cell C1 as a reference in cell C1. When a circular reference error happens, there is a non-ending loop in the cell. Reference the cell A3 is dependent on the value of cell A3 and the value of A3 is dependent on reference to cell A3.

insert a timestamp in excel with circular reference loop

But when a circular reference is entered, Excel doesn’t calculate it and the non-ending loop never starts.

Here’s the deal:

You can enable the “iterative calculation option” to force Excel to perform the calculation at least one time and use the now function in the calculation. This way Excel will update the cell formula only one time instead of every time. Steps to enable iterative calculation option:

  1. Go to File ➜ Options.
  2. In the Excel options, select Formulas.
  3. In the Calculated options, check the Enable iterative calculation option.
  4. Click OK.
insert a timestamp in excel with circular reference activate iteration

After that in cell B2, enter the below formula in the formula bar.

=IF(A2<>"",IF(B2<>"",B2,NOW()),"")
insert a timestamp in excel with circular reference enter formula

Now when you enter any value in cell A2 the formula in cell B2 will return a timestamp.

insert a timestamp in excel with circular reference enter value

If you are a VBA freak then I’m sure you’ll find this VBA code useful. With this, you don’t need to enter a formula or even not use any shortcut key. Just select the cell where you need to enter a timestamp and run the macro.

Sub timeStamp()

Dim ts As Date

With Selection

.Value = Now
.NumberFormat = "m/d/yyyy h:mm:ss AM/PM"

End With

End Sub

How to use this code

To use this code you can add it on QAT (quick access toolbar) and run it every time whenever you need to add a timestamp.

Here are the steps:

Now you have an icon on QAT and whenever you need a timestamp you can select the cell and click this button to insert it.

4.1 Using UDF for Timestamp

Yes, you can also create a custom Excel function for inserting a timestamp in Excel. Below is the code for this UDF.

Function Timestamp(Reference As Range)
If Reference.Value <> "" Then
Timestamp = Format(Now, "dd-mm-yyyy hh:mm:ss")
Else
Timestamp = ""
End If
End Function 

By using this user-defined function you can get a timestamp in a cell if another has a value in it. Please follow the below steps:

  • Go to Developer tab and open VBA editor.
  • In VBA editor, insert a new module and paste this code into it.
  • Now, close VBA editor and come back to your worksheet.
  • In the cell B2, enter below formula.
    insert-a-timestamp-in-excel-vba-function
  • Now, when you enter any value in cell A1, cell B1 will get a timestamp.

Conclusion

Adding a timestamp is something we often do while working in Excel. And, you have 5 different methods to insert it. If you ask me I love to use the VBA button on QAT for this. The best way is to add this code in a personal.xlsb so that you can use it in all the workbooks. This is the whole story about timestamps and I’m sure you found it useful but now tell me one thing.

Do you know any other method for this?

Please share with me in the comment section, I’d love to hear from you, and please don’t forget to share this tip with your friends.

If you want to sharpen your existing Excel Skills, check out these Excel Tips and Tricks.

Return to Excel Formulas List

Download Example Workbook

Download the example workbook

This tutorial will demonstrate how to convert a time in Excel’s format to Unix time in Excel and Google Sheets.

mf convert time to unix times

What is Unix Time?

Unix time is also known as Epoch Time or POSIX time or Unix timestamp. It’s a system that counts the number of seconds that have elapsed since the Unix Epoch, i.e. January 1st, 1970. To put in simple words, Unix time is the total number of seconds between a date and Unix Epoch.

Convert Excel Time to Unix Time

To calculate Unix time, first, we need to find the total number of days between the Excel time and Epoch time. Then multiply the calculated days by 86,400, because a day has 86,400 seconds (24 hours × 60 minutes ×60 seconds = 86,400 seconds).

=(B5-DATE(1970,1,1))*86400

convert excel time to unix timestamp in excel

Step by Step Explanation

The first step in the conversion of Excel time to Unix time is to calculate the numeric value of the Epoch date. This can be done by using the DATE function.

=DATE(1970,1,1)

It gives us this value:

=25569

In the same way, the calculation of the numeric value of Epoch date is subtracted from the given Excel time’s numeric value

=(B5-DATE(1970,1,1))

=(40422-25569)
=(14853)

After that, the difference calculated from above is multiplied by 86400 to get the resultant value in seconds

=(14853)*86400

This is the total number of seconds, we get, between two dates

=1283299200

Convert Unix Time to Excel Time

Inversely, we can convert the Unix time to Excel time with the help of the following formula:

=(B3/86400)+DATE(1970,1,1)

unix timestamp to excel dateStep By Step Explanation

First, the Unix timestamp is divided by the total number of seconds in a day, i.e. 86400.

=B3/86400

=14853

Now, we calculate the numeric value of the Epoch date through DATE function

=DATE(1970,1,1)

=25569

Once we have the numeric value of the Epoch date, we’ll add these two values

= 14853 + 25569
= 40422

The resultant value, we got after the calculation, is in the serial date number format. To view it in date format, simply change the format of the cell to Date or your required custom format from the Number Format by accessing it through the Home Tab

date-format-hometab

or by pressing CTRL + 1

format cells

After changing the format of the numeric values of the Excel date & time, we get the following Excel date and time

convert unix time to excel date

Convert Excel Time to Unix Time in Google Sheets

The conversion formula for time to Unix time works exactly the same in Google Sheets as in Excel.

convert exceltime to unix timestamp in google sheets

Временная метка Unix также называется временем эпохи или временем POSIX, которое широко используется во многих операционных системах или форматах файлов. В этом руководстве обсуждается преобразование даты в метку времени Unix в Excel.

Преобразовать дату в метку времени

Преобразование даты и времени в метку времени

Преобразовать метку времени на дату


 Преобразовать дату в метку времени

Просмотр и редактирование с вкладками нескольких книг Excel / документов Word, таких как Firefox, Chrome, Интернет 10!

Возможно, вы знакомы с просмотром нескольких веб-страниц в Firefox / Chrome / IE и можете переключаться между ними, легко щелкая соответствующую вкладку. Здесь вкладка Office поддерживает аналогичную обработку, позволяя просматривать несколько книг Excel или документов Word в одном окне Excel или Word и легко переключаться между ними, щелкая вкладку. ЧтобыНажмите на бесплатную 45-дневную пробную версию Office Tab!

Чтобы преобразовать дату в метку времени, вы можете использовать формулу для решения проблемы.

Выберите пустую ячейку и введите эту формулу = (A1-DATE (1970,1,1)) * 86400 Enter и нажмитевойтиKey, при необходимости, вы можете применить диапазон этой формулы, перетащив маркер автозаполнения. Теперь ряд ячеек даты преобразован в отметки времени Unix.
DOC- -UNIX 1


 Преобразование даты и времени в метку времени

Существует формула, которая поможет вам преобразовать дату и время в метку времени Unix.

1. Во-первых, вам нужно ввести всемирное координированное время в ячейку 01.01.1970. Смотрите скриншот:

2. Затем введите эту формулу = (A1- $ C $ 1) * 86400 в ячейку, нажмитеВойтиKey и при необходимости используйте эту формулу, чтобы перетащить дескриптор автозаполнения в диапазон. Смотрите скриншот:
DOC- -UNIX 3

подсказки: В формуле A1 — это ячейка даты и времени, а C1 — введенная вами координата мирового времени.


 Преобразовать метку времени на дату

Если у вас есть список меток времени, которые необходимо преобразовать в даты, вы можете выполнить следующие действия:

1. В пустой ячейке рядом со списком отметок времени введите эту формулу = (((A1 / 60) / 60) / 24) + ДАТА (1970,1,1), нажмитевойтиButton, а затем перетащите маркер автозаполнения в нужный диапазон.DOC- -UNIX 4

2. Затем щелкните правой кнопкой мыши ячейку, в которой используется формула, и выберитеФормат ячейкиИз контекстного меню, а затем во всплывающемФормат ячейкиДиалоговое окно под NУмбраЯрлык, щелкнитеДатаВкатегорияСписок, а затем выберите тип даты справа.
DOC- -UNIX 5

3. НажмитеOK, Теперь вы можете видеть, что метка времени Unix была преобразована в дату.
DOC- -UNIX 6

незамедлительный:

1. A1 представляет нужную ячейку с отметкой времени.

2. Эту формулу также можно использовать для преобразования серии отметок времени в дату и время, просто отформатируйте результат в формате даты и времени.


Перепечатано:https://www.extendoffice.com/zh-CN/documents/excel/2473-excel-timestamp-to-date.html


Do you know how to add or insert the date and the timestamp in Excel? In this blog, we would unlock multiple ways to insert the date and the timestamp in an Excel cell.

So let us now begin with it.

Table of Contents

  1. Use Keyboard Shortcut to Insert Date and Timestamp
  2. Insert Date and Timestamp Using Excel Formula
    1. Insert Only Date Using =TODAY() Function
    2. Insert Date and Timestamp Using =NOW() Function:

Use Keyboard Shortcut to Insert Date and Timestamp

There is no direct shortcut to insert the dates and times in a single cell in an Excel worksheet.

However, you can use two different shortcuts to insert the date and time. One shortcut would be to insert the date and another to insert the time.

Keyboard shortcut to insert the date in an excel cell: Hold the control key and press the colon key.

Ctrl + Colon Keyboard Shortcut

Keyboard shortcut to insert the timestamp in a cell: Hold the control and Shift key and then press the colon key on your keyboard.

Ctrl + Shift + Colon Keyboard Shortcut

Refer the below screenshot for the result:

Date and Time Keyboard Shortcut Result

It is important to note that the date and the timestamp are taken from your current system date and time.

Also, it is not a dynamic formula. It means that the date and timestamp would not refresh when you close this workbook and open it again. The date and the time remain as it is (static).

Insert Date and Timestamp Using Excel Formula

As mentioned above, when you use the keyboard shortcut method, the date/timestamp does not update automatically when you open the workbook again. 

To update the date and timestamp whenever you open the workbook, you need to use Excel formulas.

How to Insert Date and Timestamp in Excel

Insert Only Date Using =TODAY() Function

Enter the formula =TODAY() in the cell where you want to insert the date. 

Using TODAY Formula in Excel

Make sure that the format of the cell is the Date and the Time format.

This is a dynamic formula and would update each time you would open the workbook.

Insert Date and Timestamp Using =NOW() Function:

Use the formula =NOW() to insert the date as well as a timestamp in a cell. 

This is also a dynamic formula and would update each time you would open the workbook.

Using NOW Formula in Excel

This brings us to the end of this blog.

RELATED POSTS

  • DAY Function in Excel – Get Day Value From Date

  • TODAY Function in Excel – Get Today’s Date in Excel Cell

  • What is Date and Time Format in Excel?

  • Four Ways to Run A Macro in Excel

  • Start Automation – Record A Macro in Excel

  • How to Lock and Protect the Cells in Excel

Here is a mapping for reference, assuming UTC for spreadsheet systems like Microsoft Excel:

                         Unix  Excel Mac    Excel    Human Date  Human Time
Excel Epoch       -2209075200      -1462        0    1900/01/00* 00:00:00 (local)
Excel ≤ 2011 Mac† -2082758400          0     1462    1904/12/31  00:00:00 (local)
Unix Epoch                  0      24107    25569    1970/01/01  00:00:00 UTC
Example Below      1234567890      38395.6  39857.6  2009/02/13  23:31:30 UTC
Signed Int Max     2147483648      51886    50424    2038/01/19  03:14:08 UTC

One Second                  1       0.0000115740…             —  00:00:01
One Hour                 3600       0.0416666666…             ―  01:00:00
One Day                 86400          1        1             ―  24:00:00

*  “Jan Zero, 1900” is 1899/12/31; see the Bug section below. Excel 2011 for Mac (and older) use the 1904 date system.

As I often use awk to process CSV and space-delimited content, I developed a way to convert UNIX epoch to timezone/DST-appropriate Excel date format:

echo 1234567890 |awk '{ 
  # tries GNU date, tries BSD date on failure
  cmd = sprintf("date -d@%d +%%z 2>/dev/null || date -jf %%s %d +%%z", $1, $1)
  cmd |getline tz                                # read in time-specific offset
  hours = substr(tz, 2, 2) + substr(tz, 4) / 60  # hours + minutes (hi, India)
  if (tz ~ /^-/) hours *= -1                     # offset direction (east/west)
  excel = $1/86400 + hours/24 + 25569            # as days, plus offset
  printf "%.9fn", excel
}'

I used echo for this example, but you can pipe a file where the first column (for the first cell in .csv format, call it as awk -F,) is a UNIX epoch. Alter $1 to represent your desired column/cell number or use a variable instead.

This makes a system call to date. If you will reliably have the GNU version, you can remove the 2>/dev/null || date … +%%z and the second , $1. Given how common GNU is, I wouldn’t recommend assuming BSD’s version.

The getline reads the time zone offset outputted by date +%z into tz, which is then translated into hours. The format will be like -0700 (PDT) or +0530 (IST), so the first substring extracted is 07 or 05, the second is 00 or 30 (then divided by 60 to be expressed in hours), and the third use of tz sees whether our offset is negative and alters hours if needed.

The formula given in all of the other answers on this page is used to set excel, with the addition of the daylight-savings-aware time zone adjustment as hours/24.

If you’re on an older version of Excel for Mac, you’ll need to use 24107 in place of 25569 (see the mapping above).

To convert any arbitrary non-epoch time to Excel-friendly times with GNU date:

echo "last thursday" |awk '{ 
  cmd = sprintf("date -d "%s" +"%%s %%z"", $0)
  cmd |getline
  hours = substr($2, 2, 2) + substr($2, 4) / 60
  if ($2 ~ /^-/) hours *= -1
  excel = $1/86400 + hours/24 + 25569
  printf "%.9fn", excel
}'

This is basically the same code, but the date -d no longer has an @ to represent unix epoch (given how capable the string parser is, I’m actually surprised the @ is mandatory; what other date format has 9-10 digits?) and it’s now asked for two outputs: the epoch and the time zone offset. You could therefore use e.g. @1234567890 as an input.

Bug

Lotus 1-2-3 (the original spreadsheet software) intentionally treated 1900 as a leap year despite the fact that it was not (this reduced the codebase at a time when every byte counted). Microsoft Excel retained this bug for compatibility, skipping day 60 (the fictitious 1900/02/29), retaining Lotus 1-2-3’s mapping of day 59 to 1900/02/28. LibreOffice instead assigned day 60 to 1900/02/28 and pushed all previous days back one.

Any date before 1900/03/01 could be as much as a day off:

Day        Excel   LibreOffice
-1            -1    1899/12/29
 0    1900/01/00*   1899/12/30
 1    1900/01/01    1899/12/31
 2    1900/01/02    1900/01/01
 …
59    1900/02/28    1900/02/27
60    1900/02/29(!) 1900/02/28
61    1900/03/01    1900/03/01

Excel doesn’t acknowledge negative dates and has a special definition of the Zeroth of January (1899/12/31) for day zero. Internally, Excel does indeed handle negative dates (they’re just numbers after all), but it displays them as numbers since it doesn’t know how to display them as dates (nor can it convert older dates into negative numbers). Feb 29 1900, a day that never happened, is recognized by Excel but not LibreOffice.

13 Answers

  1. From a timestamp in milliseconds (ex: 1488380243994) use this formula: =A1/1000/86400+25569. with this formater: yyyy-mm-dd hh:mm:ss.000.
  2. From a timestamp in seconds (ex: 1488380243) use this formula: =A1/86400+25569. with this formater: yyyy-mm-dd hh:mm:ss.

Contents

  • 1 How do I turn a timestamp into a date?
  • 2 How do I convert a timestamp to a date in sheets?
  • 3 How do I convert time to epoch?
  • 4 What is the format of timestamp?
  • 5 What is the Datevalue function in Excel?
  • 6 How do I extract the date from a time stamp?
  • 7 How do I manually convert a timestamp to a date?
  • 8 How do I convert a timestamp to a date in SQL?
  • 9 What is epoch date?
  • 10 How do I format a timestamp in Excel?
  • 11 How do I change the format of the date in Excel?
  • 12 How do you format a timestamp?
  • 13 How do I convert Datevalue to date?
  • 14 How do I extract date from datetime in Excel?
  • 15 How do I convert 8 digits to dates in Excel?
  • 16 How do I convert a timestamp to a MONTH in Excel?
  • 17 How do I extract the day from a timestamp in Excel?
  • 18 What is Eomonth formula in Excel?
  • 19 How do I convert timestamp to time in Excel?
  • 20 How do I convert UTC timestamp to local time in Excel?

How do I turn a timestamp into a date?

Let’s see the simple example to convert Timestamp to Date in java.

  1. import java.sql.Timestamp;
  2. import java.util.Date;
  3. public class TimestampToDateExample1 {
  4. public static void main(String args[]){
  5. Timestamp ts=new Timestamp(System.currentTimeMillis());
  6. Date date=new Date(ts.getTime());
  7. System.out.println(date);
  8. }

How do I convert a timestamp to a date in sheets?

1 Answer. You can extract the date portion of the timestamp using MID() then use DATEVALUE() to convert it to date format. Then use Format > Number > Date command.

How do I convert time to epoch?

The Unix epoch is the time 00:00:00 UTC on 1 January 1970. UNIX epoch time can be converted into local time by dividing it by 86400 and adding result to epoch date in days.

What is the format of timestamp?

The default format of the timestamp contained in the string is yyyy-mm-dd hh:mm:ss. However, you can specify an optional format string defining the data format of the string field.

What is the Datevalue function in Excel?

Description. The DATEVALUE function is helpful in cases where a worksheet contains dates in a text format that you want to filter, sort, or format as dates, or use in date calculations. To view a date serial number as a date, you must apply a date format to the cell.

PostgreSQL – How to extract date from a timestamp?

  1. SELECT DATE(column_name) FROM table_name;
  2. SELECT ‘2018-07-25 10:30:30’::TIMESTAMP::DATE;
  3. SELECT DATE(SUBSTRING(‘2018-07-25 10:30:30’ FROM 1 FOR 10));

How do I manually convert a timestamp to a date?

In this article, we will show you how to convert UNIX timestamp to date.
Convert Timestamp to Date.

1. In a blank cell next to your timestamp list and type this formula =R2/86400000+DATE(1970,1,1), press Enter key.
3. Now the cell is in a readable date.

How do I convert a timestamp to a date in SQL?

We can convert the timestamp to date time with the help of FROM_UNIXTIME() function. Let us see an example. First, we will create a table with column of int type. Then we convert it to timestamp and again into date time.

What is epoch date?

In a computing context, an epoch is the date and time relative to which a computer’s clock and timestamp values are determined. The epoch traditionally corresponds to 0 hours, 0 minutes, and 0 seconds (00:00:00) Coordinated Universal Time (UTC) on a specific date, which varies from system to system.

How do I format a timestamp in Excel?

Insert Date and Timestamp Using NOW Function

  1. Right-click on the cell and select ‘Format cells’.
  2. In the Format Cells dialog box, select ‘Custom’ category in the Number tab.
  3. In the Type field, enter dd-mm-yyyy hh:mm:ss.
  4. Click OK.

How do I change the format of the date in Excel?

Follow these steps:

  1. Select the cells you want to format.
  2. Press Control+1 or Command+1.
  3. In the Format Cells box, click the Number tab.
  4. In the Category list, click Date.
  5. Under Type, pick a date format.

How do you format a timestamp?

The timestamp is parsed either using the default timestamp parsing settings, or a custom format that you specify, including the time zone.
Automated Timestamp Parsing.

Timestamp Format Example
yy-MM-dd HH:mm:ss,SSS 10-06-26 02:31:29,573
yy-MM-dd HH:mm:ss 10-04-19 12:00:17
yy/MM/dd HH:mm:ss 06/01/22 04:11:05

How do I convert Datevalue to date?

The DATEVALUE function in Excel converts a date in the text format to a serial number that Excel recognizes as a date. So, the formula to convert a text value to date is as simple as =DATEVALUE(A1) , where A1 is a cell with a date stored as a text string.

Extract date from a date and time

  1. Generic formula. =INT(date)
  2. To extract the date part of a date that contains time (i.e. a datetime), you can use the INT function.
  3. Excel handles dates and time using a scheme in which dates are serial numbers and times are fractional values.
  4. Extract time from a date and time.

How do I convert 8 digits to dates in Excel?

To do this, select a cell or a range of cells with the numbers you want to convert to dates and press Ctrl + 1 to open the Format Cells dialog box. On the Number tab, choose Date, select the desired date format in Type and click OK. If have any issues I will be here to help you. Thanks!

How do I convert a timestamp to a MONTH in Excel?

MONTH function in Excel – get month number from date.
This is the most obvious and easiest way to convert date to month in Excel. For example: =MONTH(A2) – returns the month of a date in cell A2. =MONTH(DATE(2015,4,15)) – returns 4 corresponding to April.

Extract the day number
The getting day number formula is as simple as the formulas above. Please do as follows. Copy and paste formula =DAY(A2) into a blank cell D2 and press Enter key. Then drag the Fill Handle down to the range to extract all day numbers from the referenced date list.

What is Eomonth formula in Excel?

Description. The Microsoft Excel EOMONTH function calculates the last day of the month after adding a specified number of months to a date. The result is returned as a serial date. The EOMONTH function is a built-in function in Excel that is categorized as a Date/Time Function.

To convert time to a number of hours, multiply the time by 24, which is the number of hours in a day. To convert time to minutes, multiply the time by 1440, which is the number of minutes in a day (24*60). To convert time to seconds, multiply the time time by 86400, which is the number of seconds in a day (24*60*60 ).

How do I convert UTC timestamp to local time in Excel?

Convert UTC/GMT time to local time with formulas
(2) The formula =A2 + (9 / 24) will return a decimal number. For converting the decimal number to time, please select the decimal number, and click Home > Number Format > Time.

Like this post? Please share to your friends:
  • Date and time for excel
  • Date and text excel
  • Date add years in excel
  • Dataset to excel sheet
  • Datanumen word repair что это