Using IF function to calculate hours worked - non military time

1. Using IF function to calculate hours worked - non military time

Hello, I've tried googling this but I'm struggling to understand how to use the IF function to calculate hours worked without using military time and without adding "AM/PM" to every shift entry. To avoid confusion over am/pm hours on 12-hour time, I want a formula that says "(If TimeOut is less than TimeIn, then add 12 hours) - Time In = total hours worked. I want to do that for the morning shift, and the afternoon shift and then add them together for total hours worked.

The formula I'm trying to use right now is :=IF(C4<B4,C4+12,C4)-B4 but I'm doing something wrong because it's simply giving me 12 no matter what my clock in/clock out times are. Does this make sense?

2. Re: Using IF function to calculate hours worked - non military time

When I put 7 in B4 and 5 in C4 the formula yields 10 (D4).

3. Re: Using IF function to calculate hours worked - non military time

If C4 and B4 are real excel time values, then Adding 12 is actually adding 12 DAYS, not hours.

Try
=IF(C4<B4,C4+"12:00:00",C4)-B4

4. Re: Using IF function to calculate hours worked - non military time

Assuming you have regular times in C4 and B4, what you see is not what you get. In Excel, the day (24 hours) is treated as a single unit of time. 1 = 1 day so when you are adding 12, you are adding 12 days. Time is a fraction of 1, 1 hour = 1/24 and so on. 12 hours = half a day so = 0.5

:=IF(C4<B4,C4+0.5,C4)-B4

5. Re: Using IF function to calculate hours worked - non military time

Thank you guys! The "12" vs "12:00:00" solved my problem. It's working beautifully now. I'd almost lost my mind. Very much appreciated, y'all are amazing!! !

6. Re: Using IF function to calculate hours worked - non military time

thank you Chemist, this is basically what I did. Your explanation really helped me understand what I was doing wrong, I really appreciate you taking the time to help me!

7. Re: Using IF function to calculate hours worked - non military time

You're welcome.

8. Re: Using IF function to calculate hours worked - non military time

There are currently 1 users browsing this thread. (0 members and 1 guests)