
Originally Posted by
daddylonglegs
Perhaps there won't be any times around midnight but what if C5 = 12.3 and D5 = a signifying half past midnight, that formula treats the time like 12:30 PM
I suggest this version
=((TEXT(E5*100,"0\:00 ")&F5)-(TEXT(C5*100,"0\:00 ")&D5))*24
You do provide a good point about 12:30am for C5 and D5. That just made me realize something else. If C5=11.3 and D5=p while E5=1.3 and F5=a, it provides the hours "owed" instead of the actual hours. Not, that I couldn't solve this but there is probably a more efficient way than formulating it with an if function similar to the one shown below...
=IF((((TEXT(E11*100,"0\:00 ")&F11)-(TEXT(C11*100,"0\:00 ")&D11))*24)<0,(((TEXT(E11*100,"0\:00 ")&F11)-(TEXT(C11*100,"0\:00 ")&D11))*24)+24,(((TEXT(E11*100,"0\:00 ")&F11)-(TEXT(C11*100,"0\:00 ")&D11))*24))
Basically if the value is negative, it adds 24 hours to make it correct or leaves it as is if the difference is already positive. It seems a bit redundant the way I did it...
Bookmarks