I'm not sure what you want to do when your time goes past midnight, but if it's
based on subtracting two times, you can do things like:
=(A1-B1)+(B1>A1)
which is shorthand for:
=(A1-B1)+IF(B1>A1,1,0)
If you really are subtracting times, it might be a good idea to include both the
time and date in those cells. Then you don't have to worry about going across 2
midnights.