Home » excel » excel – Time subtraction with ms involved

excel – Time subtraction with ms involved

Posted by: admin May 14, 2020 Leave a comment


I have a csv file with data like this:






The goal is to calculate the time difference from the row above.
For example, the duration from row 1 to row 2 = 1000ms + 652-445ms = 1207 ms

How to&Answers:

First, load your CSV to excel and parse by using text to columns like below:

enter image description here

Result will be like this:

enter image description here

Use this formula in G1 to get the millisecond difference.


And there you have your millisecond difference.


Excel doesn’t know about milliseconds. When you load your CSV, those “19:1:6:445” entries will come in as text. You’ll have to add some formulas to parse them semi-manually. The mutant-date entries will end up in column C, so I’ll put formulas starting in column D and going to the right.

In D1, find the position of that third colon, the one that delimits off the milliseconds.

=FIND(":", C1, FIND(":", C1, FIND(":", C1, 1)+1)+1)

In E1, get the date value that Excel can parse, the part with seconds and larger.


and in F1, the date value of the milliseconds portion. That division? Seconds per hour, hours per day, milliseconds per second.


Now, recombine the two in G1,


and fill those columns down to get the values-with-milliseconds for all the imported cells. The differences in milliseconds can start in row 2, so in H2 you put


which converts back to readable milliseconds.

If you know anything about formulas, it shouldn’t be hard to combine columns E, F, and G, but I left them separate for clarity’s sake. Also note that you’re dealing with floating point values here; this means that you will get an occasional off-by-one error.