Results 1 to 2 of 2
Thread: Time formula problem
2009-11-25, 05:43 #1
- Join Date
- Aug 2001
- Surrey, United Kingdom
- Thanked 0 Times in 0 Posts
I have problems with a formula and would appreciate some help
I have 2 columns both formatted as [h]:mm the 3rd has the formula I2-J2 and is also formatted as [h]:mm which is fine if the time in I2 is higher than J2 but returns #### if I2 is less than J2. I have read through Chip Pearsons site Date Arithmatic which shows this
You can determine the number of hours and minutes between two times by subtracting the two times. However, since Excel cannot handle negative times, you must use an =IF statement to adjust the time accordingly. If your times were entered without a date (e.g, 22:30), the following statement will compute the interval between two times in A1 and B1 .
The "+1" in the formula causes Excel to treat B1 as if it were in the next day, so 02:30-22:00 will result in 4:30, four hours and thirty minutes, which is what we would expect. To covert this to a decimal number, for example, 4.5, indicating how many hours, multiply the result by 24 and format the cell as General or Decimal, as in
So I have entered this =24*(IF(I2>J2,J2+1-I2,J2-I2)) the time in I2 = 48:00 and J2 = 44:10 but with the target cell formatted as [h]:mm I get a result of 484, If I format it as General I get 20.166 recurring and if I format it as Number I get 20.17?
The examples in the graphic below show my original formula in L and Chip's in M
Any ideas pleaseCheers
Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)
2009-11-25, 06:11 #2
- Join Date
- Mar 2002
- Thanked 29 Times in 29 Posts
1. Chip Pearson's formulas are intended for clock time, not for cumulative time.
2. The result of the formula, as explicitly stated, is the number of hours converted to a decimal number, so you shouldn't format it as time.
Try this formula instead:
and format the result as General or as Number with the desired number of decimal places.