View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default single cell time entry as time - time; Ever seen this?

"Claus Busch" wrote:
=LEFT(A2,FIND(" -",A2)-1) gives me 7:00 but if I check it against
Time(7,,) I get FALSE.


Because in that context, you are comparing the string "7:00" with the number
TIME(7,0,0). Try:

=--LEFT(A2,FIND(" -",A2)-1)

With that formula in B2, =B2-TIME(7,0,0)=0 returns TRUE.

Your original formula was essentially:

=MID(A1,FIND("- ",A1)+2,99)-LEFT(A1,FIND(" ",A1)-1)

In that context, we do not need --MID(...) and --LEFT(...) because __any__
arithmetic operation (subtraction, in this case) is sufficient to convert
the time strings to numeric time.