+ Reply to Thread
Results 1 to 4 of 4

IF FUNCTION for time

  1. #1
    Registered User
    Join Date
    06-06-2013
    Location
    Manila
    MS-Off Ver
    Excel Mac 2011
    Posts
    8

    Lightbulb IF FUNCTION for time

    For example, an employee is given 1 hour lunch break everyday. On a particular day, he has a time in of 12:15pm and time out of 1:18pm for lunch hour. He was late for 2 minutes.

    If I input the time in and time out in each cell, what formula do I have to use for excel to automatically regard and input it on another cell as late for 2 minutes? And if he's not late, no action should be done. I figured using the IF FUNCTION would be my best bet, but I have trouble figuring out how to construct the formula.

    Thank you for your help! If you need any more info, just ask me

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,942

    Re: IF FUNCTION for time

    Assuming your data is in A1 (12:15) and B1 (1:18), use this...
    =IF(B1-A1>1/24,B1-A1,"")
    This will calce to ONE hour
    Keep in mind that as far as excel is concerned, it treats time as a fraction/decimal of 1 (day). So 6:00am is actually 0.25, 12:00 mid-day is 0.5 etc
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    06-06-2013
    Location
    Manila
    MS-Off Ver
    Excel Mac 2011
    Posts
    8

    Re: IF FUNCTION for time

    Quote Originally Posted by FDibbins View Post
    Assuming your data is in A1 (12:15) and B1 (1:18), use this...
    =IF(B1-A1>1/24,B1-A1,"")
    This will calce to ONE hour
    Keep in mind that as far as excel is concerned, it treats time as a fraction/decimal of 1 (day). So 6:00am is actually 0.25, 12:00 mid-day is 0.5 etc
    Thank you for your reply! But what if the time is in Sheet 1 and I need to input the late time in Sheet 2?

    And do I change the 1/24 to 1/1440 if I want it in minutes?

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,942

    Re: IF FUNCTION for time

    Not sure which sheet will have which time on it, so modify this to suite your needs...
    =IF(Sheet1!A1-A1>1/24,B1-A1,"")
    It is the same as...
    =IF(B1-A1>1/24/60,B1-A1,"")
    it just references another sheet

    Not sure why you would want to use minutes, the formula tests for any time in excess of 1 hour.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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