Working with time DURATION, not time of day

后端 未结 9 909
后悔当初
后悔当初 2020-12-13 17:07

I\'m doing some benchmarking, and I want to use Excel to produce graphs of the results. I\'ve got a simple but annoying problem which is baking my noodle.

The proble

相关标签:
9条回答
  • 2020-12-13 17:11

    You can easily do this with the normal "Time" data type - just change the format!

    Excels time/date format is simply 1.0 equals 1 full day (starting on 1/1/1900). So 36 hours would be 1.5. If you change the format to [h]:mm, you'll see 36:00.

    Therefore, if you want to work with durations, you can simply use subtraction, e.g.

    A1: Start:           36:00 (=1.5)
    A2: End:             60:00 (=2.5) 
    A3: Duration: =A2-A1 24:00 (=1.0)
    
    0 讨论(0)
  • 2020-12-13 17:13

    I don't know how to make the chart label the axis in the format "X1 min : X2 sec", but here's another way to get durations, in the format of minutes with decimals representing seconds (.5 = 30 sec, .25 = 15 sec, etc.)

    Suppose in column A you have your time data, for example in cell A1 you have 12:03:06, which your 3min 6sec data misinterpreted as 3:06 past midnight, and column B is free.

    In cell B1 enter this formula: =MINUTE(A1) + SECOND(A1)/60 and hit enter/return. Grab the lower right corner of cell B2 and drag as far down as the A column goes to apply the formula to all data in col A.

    Last step, be sure to highlight all of column B and set it to Number format (the application of the formula may have automatically set format to Time).

    0 讨论(0)
  • 2020-12-13 17:16

    The custom format hh:mm only shows the number of hours correctly up to 23:59, after that, you get the remainder, less full days. For example, 48 hours would be displayed as 00:00, even though the underlaying value is correct.

    To correctly display duration in hours and seconds (below or beyond a full day), you should use the custom format [h]:mm;@ In this case, 48 hours would be displayed as 48:00.

    Cheers.

    0 讨论(0)
  • 2020-12-13 17:24

    What I wound up doing was: Put time duration in by hand, e.g. 1 min, 03 sec. Simple but effective. It seems Excel overwrote everything else, even when I used the 'custom format' given in some answers.

    0 讨论(0)
  • 2020-12-13 17:27

    Use format d "days" h:mm:ss or [h]:mm:ss, depending on your needs.

    Say you have a duration of 30h 12m 54s:

    • h:mm:ss -> 6:12:54 (not correct for a duration)
    • [h]:mm:ss -> 30:12:54
    • d "days" h:mm:ss -> 1 days 6:12:54

    Variations are possible: I like something like d"d" h"h" mm"m" ss"s" which formats as 1d 6h 12m 54s.

    0 讨论(0)
  • 2020-12-13 17:27

    The best way I found to resolve this issue was by using a combination of the above. All my cells were entered as a Custom Format to only show "HH:MM" - if I entered in "4:06" (being 4 minutes and 6 seconds) the field would show the numbers I entered correctly - but the data itself would represent HH:MM in the background.

    Fortunately time is based on factors of 60 (60 seconds = 60 minutes). So 7H:15M / 60 = 7M:15S - I hope you can see where this is going. Accordingly, if I take my 4:06 and divide by 60 when working with the data (eg. to total up my total time or average time across 100 cells I would use the normal SUM or AVERAGE formulas and then divide by 60 in the formula.

    Example =(SUM(A1:A5))/60. If my data was across the 5 time tracking fields was the 4:06, 3:15, 9:12, 2:54, 7:38 (representing MM:SS for us, but the data in the background is actually HH:MM) then when I work out the sum of those 5 fields are, what I want should be 27M:05S but what shows instead is 1D:03H:05M:00S. As mentioned above, 1D:3H:5M divided by 60 = 27M:5S ... which is the sum I am looking for.

    Further examples of this are: =(SUM(G:G))/60 and =(AVERAGE(B2:B90)/60) and =MIN(C:C) (this is a direct check so no /60 needed here!).

    Note that your "formula" or "calculation" fields (average, total time, etc) MUST have the custom format of MM:SS once you have divided by 60 as Excel's default thinking is in HH:MM (hence this issue). Your data fields where you are entering in your times should need to be changed from "General" or "Number" format to the custom format of HH:MM.

    This process is still a little bit cumbersome to use - but it does mean that your data entry is still entered in very easy and is "correctly" displayed on screen as 4:06 (which most people would view as minutes:seconds when under a "Minutes" header). Generally there will only be a couple of fields needing to be used for formulas such as "best time", "average time", "total time" etc when tracking times and they will not usually be changed once the formula is entered so this will be a "one off" process - I use this for my call tracking sheet at work to track "average call", "total call time for day".

    0 讨论(0)
提交回复
热议问题