+ Reply to Thread
Results 1 to 7 of 7

Finding average time between list of timestamps

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    New York, New York
    MS-Off Ver
    Excel 2012
    Posts
    4

    Finding average time between list of timestamps

    I'm trying to find the average time between each timestamp. I want to calculate the time between each two stamps and put it in a field next to the times, then I want to calculate the average time between them as a total. The data does span multiple days, so date needs to be taken into account as well.

    2012-07-11 08:42:19,674
    2012-07-11 08:42:20,562
    2012-07-11 08:42:21,000
    2012-07-11 08:42:21,526
    2012-07-11 08:42:21,997
    2012-07-11 08:42:22,408
    2012-07-11 08:42:22,900
    2012-07-11 08:42:23,315
    2012-07-11 08:42:23,707

    Format is Year-Month-Date Hours:Mins:Secs,MSecs

    Output I'm looking for is something like this:

    2012-07-11 08:42:19,674
    2012-07-11 08:42:20,562 888
    2012-07-11 08:42:21,000 438
    2012-07-11 08:42:21,526 526
    2012-07-11 08:42:21,997 471
    2012-07-11 08:42:22,408 589
    2012-07-11 08:42:22,900 492
    2012-07-11 08:42:23,315 415
    2012-07-11 08:42:23,707 392
    >>>>>>>>>>>>>>>>>>> 526.375

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Finding average time between list of timestamps

    If your timestamps are in a valid time format then you should be able to just subtract one from the other, so if they start in A2 try this formula in B3 copied down

    =(A3-A2)*86400*1000

    that will give you the difference in milliseconds (format B3 as general).

    Copy that formula down the column and then you can just use a regular AVERAGE formula to average the differences.

    If you want you can get the average without even computing the individual differences because that will just be the difference between then first and last values divided by the total number of values -1, i.e.

    =(MAX(A:A)-MIN(A:A))*86400*1000/(COUNT(A:A)-1)
    Audere est facere

  3. #3
    Registered User
    Join Date
    08-21-2013
    Location
    New York, New York
    MS-Off Ver
    Excel 2012
    Posts
    4

    Re: Finding average time between list of timestamps

    It's actually two columns, Date > Time and around 200k rows. I'm trying to get it to time format it will recognize.
    Last edited by MinneeOT; 08-21-2013 at 03:45 PM.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Finding average time between list of timestamps

    OK, you can still that with a small adjustment, i.e. assuming dates in A2 down and times in B2 down use this formula in C2

    =(A3+B3-A2-B2)*86400*1000

    If you select C2 and put the cursor on the bottom right of the cell until you see a black "+" (that's the "fill-handle") you can double-click and the formula will populate as far down as you have data in the adjacent column

    Now just average column C

    ...or once again you can get the average difference with a single formula

    =(MAX(A:A+B:B)-MIN(A:A+B:B))*86400*1000/(COUNT(A:A)-1)

    confirmed with CTRL+SHIFT+ENTER

    The above works with valid dates and times no matter what format. You can check if the data is valid by using

    =ISNUMBER(A2+B2)

    If that gives TRUE then the formulas above should work

  5. #5
    Registered User
    Join Date
    08-21-2013
    Location
    New York, New York
    MS-Off Ver
    Excel 2012
    Posts
    4

    Re: Finding average time between list of timestamps

    First formula works perfectly, the second one outputs ######. Isnumber outputs True.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Finding average time between list of timestamps

    If row 1 contains a text header then that second formula might give you problems. You can try specifying the exact ranges like

    =(MAX(A2:A200000+B2:B200000)-MIN(A2:A200000+B2:B200000))*86400*1000/(COUNT(A:A)-1)

    Needs to be entered with CTRL+SHIFT+ENTER so that curly braces like { and } appear around the formula.

    ....but of course you don't need that one if the first formula worked.......

  7. #7
    Registered User
    Join Date
    08-21-2013
    Location
    New York, New York
    MS-Off Ver
    Excel 2012
    Posts
    4

    Re: Finding average time between list of timestamps

    No, no text headers. Just data.

    Yeah, I just averaged out the results of the first formula. Thanks for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 02-16-2013, 03:32 PM
  2. Trying to make a button that when pressed displays the timestamps in a list
    By russellwolfe1987 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-19-2012, 08:44 PM
  3. Time between timestamps excluding certain hours
    By Silaswulff in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-01-2011, 06:08 PM
  4. Finding the average time
    By Gadgets in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-31-2006, 04:06 PM
  5. Replies: 2
    Last Post: 06-16-2006, 01:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1