Formula to calculate the number of hours


Posted by mgreer on January 30, 2002 5:35 PM

Hello, I'm trying to write a formula that will calculate the number of hours in a range of cells containing times. For example: Cell A1 contains 11:00 PM. A2 contains 6:00 AM. How do I get cell A3 to sum 7 ???? I know it sounds pretty simple... I've been racking my brain trying to figure it out! Please Help!

Posted by IML on January 30, 2002 6:02 PM

you could use
=(A2+(A2<A1)-A1)*24 (format as general)

This will work as long as you only pass midnight once.

It may be preferable to enter time and date and (okday to format it so it only shows time) and use
=(A2-A1)*24

good luck

Posted by IML on January 30, 2002 6:27 PM

second try

the first formula should be
=(A2+(A2 < A1)-A1)*24



Posted by mgreer on January 30, 2002 6:41 PM

Re: second try

That did it! Thanks!