+ Reply to Thread
Results 1 to 8 of 8

Using IF function to calculate hours worked - non military time

  1. #1
    Registered User
    Join Date
    10-06-2015
    Location
    New Mexico, USA
    MS-Off Ver
    2010
    Posts
    7

    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?

    Thanks, I appreciate any help you can offer!

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2010/2019
    Posts
    11,938

    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. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    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. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,457

    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
    ChemistB
    My 2

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Registered User
    Join Date
    10-06-2015
    Location
    New Mexico, USA
    MS-Off Ver
    2010
    Posts
    7

    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. #6
    Registered User
    Join Date
    10-06-2015
    Location
    New Mexico, USA
    MS-Off Ver
    2010
    Posts
    7

    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. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

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

    You're welcome.

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,457

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

    Glad to help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Calculating percent of hours worked by shift using military time
    By seanpod in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-24-2015, 01:23 PM
  2. [SOLVED] Looking for formula help finding total hours worked in military time
    By Mic4220 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-08-2015, 02:42 PM
  3. [SOLVED] [SOLVED] Calculate time worked inside Regular Hours and Over Time
    By myxamhatosis in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-07-2015, 09:16 PM
  4. Replies: 7
    Last Post: 01-02-2015, 04:06 PM
  5. Formula tp ca;culate hours worked using military hours and standard minutes
    By Vicki Steffen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-24-2014, 03:03 PM
  6. Replies: 4
    Last Post: 02-12-2013, 07:01 AM
  7. Replies: 2
    Last Post: 02-11-2013, 02:26 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1