Link to home
Start Free TrialLog in
Avatar of agwalsh
agwalsh

asked on

Time calculation formula not assessing correctly despite being formatted as [hh]:mm

I have a file here that basically assesses if the number of hours in Bank holiday is greater than the number of hours in I1. However, even though all the hours in the cells and in i2 have been formatted as [hh]:mm, the formula is not assessing correctly. For some reason the entry in I2 , which has been entered as 40:00 and formatted as [hh]:mm, is showing as 01/01/1900  16:00:00 in the formula bar.
EE_time_format_not_working.xlsx
Avatar of Norie
Norie

It's not possible to open the file you've uploaded, seems to be a problem with the format.

How have the numbers been calculated/entered in I1?
Avatar of agwalsh

ASKER

Will re-send the file. It is in xlsx format. The hours number has been entered as 40:00
EE_time_format_not_working.xlsx
Is this better?

I've amended the formula in Bank Holiday, it doesn't appear that the formulas were referring to the correct cells originally. Also, it looks like the entry in I1 may have been incorrect. I changed it to 16:00, change it back if necessary
EE_time_format_not_working--1-.xlsx
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Norie

When I downloaded the original the cells were formatted as time, I've downloaded it again and they still show as time to me.
Norie is right. The time you see in the table are actually numbers as Text and Excel treats date and time as real numbers.

If you simply put 23:59 in any empty cell on the sheet, you will see 23:59:00 in the formula bar but as soon as you input 24:00, the formula bar will show 01/01/1900  00:00:00 because 24 hours means 1 day and 00 hours 00 minutes and 00 seconds. And 01/01/1900 means the number 1 behind the scene which you can confirm by changing the format of the cell where you entered 24:00 to General.

Same way when you enter 40:00 excel treats it as a time value and since it is greater than 24 hours, it shows 01/01/1900  16:00:00 in the formula bar as 40 hours is equal to 24 hours and 16 hours where 24 hours is equivalent to 1 day and that's why it shows 01/01/1900  16:00:00 in the formula bar.
Avatar of agwalsh

ASKER

OK, so given all that. They are formatted as numbers with time - I get I can correct them with Norie's solution - and it works beautifully - thank you @Norie :-) .  Why would it be treating them as text? They *were* got as a download from an external system...would that explain it?
That only occurred for me in I3. When I checked the format of the cells in the Table then the format was [hh]:mm.

I have downloaded the file again and added a formula =D7-B7 which works without any modifications
agwalsh

How did you get the data from the download into Excel?

Roy

I checked using ISNUMBER and ISTEXT.

When you tried =D7-B7 Excel might have coerced the values to 'real' time values.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Norie

I only tried that formula on a new download. before entering the formula  to test.

The original formulas were  checking the next row, I changed to a structured reference which seemed to fix the problem for my example workbook.
Roy

When I downloaded the workbook there was a problem with the formula in E2, it referenced D3 instead of D2.

I tried changing it to use a structured reference but for whatever reason it didn't take.
Avatar of agwalsh

ASKER

It was a sample file sent to me (external source) which I have anonymised. It has been weird but @Rob Henson's if formula to check if it's text or numbers would solve the problem - along with Norie's workaround as well. Thank you all - EE saves the day again¬
Avatar of agwalsh

ASKER

I love how I got two good workable solutions for what is a very common problem in dealing with external data sources. Thanks again to all of you.