I would like to get the difference in hours between B2 & C2 in D2. What formula would I use for this? I am new to excel and trying to learn more![]()
B2 and C2 are formatted 01/03/2016 0858
Thanks!!
I would like to get the difference in hours between B2 & C2 in D2. What formula would I use for this? I am new to excel and trying to learn more![]()
B2 and C2 are formatted 01/03/2016 0858
Thanks!!
Excel wont see 0858 as time, you will have to format the cells as Date/Time so it shows like this 08:58. Then format D2 as number and use this formula in D2....
![]()
Please Login or Register to view this content.
1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.
Tom
Thank you. The formatting must be wrong. I'm getting #VALUE and have B and C formatted as m/d/yyy [h]:mm and column D formatted as [h]:mm. Any idea why I'm not getting my value?
Is that really the value in the cells, 0858 for the time, it's not 08:58 ??B2 and C2 are formatted 01/03/2016 0858
That would explain the #Value! error, because 0858 isn't really a valid time, so the cell as a whole is just a TEXT string, not a Date+Time.
Can you attach a sample book?
Attached Sample book.
Yep, you have 2 problems with the source data.
1. your times are written as 0858 (no colon to sepate the hours:minutes) So it's not a valid time.
2. Column A has leading spaces
So this can be resolved by adjusting the source date/time values like this
C2: =TRIM(REPLACE(A2,LEN(A2)-1,0,":"))
D2: =TRIM(REPLACE(B2,LEN(B2)-1,0,":"))
Then use
=(D2-C2)*24
Thats seemed to work but then when I use =(D2-C2)*24, some of the values are incorrect. I might have a time (for example in row 4) that is showing 22 hours and 24 min difference when it is really less than an hour. I'm attaching the new sheet
named Sample Book. Any idea of what that could be?
The formula is returning the value as Number of Hours, not a TIME.
But formatting the cell as a TIME makes it look strange.
Do you want the values to be returned as an actual TIME value ? If yes, remove the *24, and format the cell as TIME
Or do you want the values returned as number of hours in decimal value ? Keep the *24, but format the cell as NUMBER with 2 decimals.
I want the number of hours. But some of them are not accurate and some are. (like in Row 4 of the sample that I attached)
Format the cells with the formula as NUMBER, not as Time.
I added a sheet of Jonmo1's solution, and also added to your formula to blank the cell if Row D is blank so that you can have the formula run down without always dragging it around.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks