+ Reply to Thread
Results 1 to 13 of 13

cannot get formula right to subtract time using if

  1. #1
    Registered User
    Join Date
    10-23-2017
    Location
    North Carolina
    MS-Off Ver
    Office 2010
    Posts
    13

    cannot get formula right to subtract time using if

    I have a column titled "event start time"(A1), a column titled " event end time" (B1) and a column titled " total event hours" (C1).
    I have the third cell formulated to return the difference in hours, but I'm looking for help with a formula to calculate if the hours = 8 or more, to automatically deduct one hour for break.
    If the time is less than 8 hours, to do nothing but just return the actual difference.
    please help.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: cannot get formula right to subtract time using if

    Maybe this?

    =IF((B1-A1)>8,B1-A1-1,B1-A1)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    10-23-2017
    Location
    North Carolina
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: cannot get formula right to subtract time using if

    that still just returns 9:00 for me.
    When A1 is 08:30 and B1 is 17:30.
    (I have it all formatted as military time)

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: cannot get formula right to subtract time using if

    Attach a sample workbook, please.

  5. #5
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: cannot get formula right to subtract time using if

    Try this:

    =B1-A1-IF(B1-A1>TIME(8,0,0),TIME(1,0,0),0)

  6. #6
    Registered User
    Join Date
    10-23-2017
    Location
    North Carolina
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: cannot get formula right to subtract time using if

    Here's the sample
    Attached Files Attached Files

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: cannot get formula right to subtract time using if

    Sorry! Try this:

    =IF(TEXT(B1-A1,"hh:mm")>8,B1-A1-VALUE("01:00"),B1-A1)

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: cannot get formula right to subtract time using if

    Try

    =IF((B1-A1)>8/24,(B1-A1)-1/24,B1-A1)

  9. #9
    Registered User
    Join Date
    10-23-2017
    Location
    North Carolina
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: cannot get formula right to subtract time using if

    @63falcondude
    this seems to be working, but when I copied the formula down, it returned a #VALUE! for only one of the cells. argghh.
    I'll figure that out eventually.
    thank you!

  10. #10
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: cannot get formula right to subtract time using if

    You're welcome. Thanks for the rep!

    There is a space in H22. Delete that and it will be working as intended.

    If that solved your question, please mark this thread as SOLVED.

  11. #11
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: cannot get formula right to subtract time using if

    Also, if you want to clean the worksheet up a bit, you can add this (in red) to the existing formula:

    =IF(H2&I2="","",I2-H2-IF(I2-H2>TIME(8,0,0),TIME(1,0,0),0))

    The formula will return blank if there is nothing in the start or end times.

  12. #12
    Registered User
    Join Date
    10-23-2017
    Location
    North Carolina
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: cannot get formula right to subtract time using if

    perfect! thank you!

  13. #13
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: cannot get formula right to subtract time using if

    You're welcome. Glad we could help.

    Welcome to the forum.

+ 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. Formula to Subtract Time if Over a Value
    By Choolio123 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-26-2015, 01:55 PM
  2. [SOLVED] Formula to subtract duration from fixed time
    By TopDog0310 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 09-22-2013, 04:19 PM
  3. Need Formula to subtract Different date and time
    By Chobi in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-17-2013, 06:03 AM
  4. Replies: 2
    Last Post: 05-31-2013, 04:37 AM
  5. [SOLVED] Formula to subtract two time stamps
    By jiminic in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-13-2013, 11:04 PM
  6. formula to subtract time, 12:10 am (00:10) - 11:50 pm (23:10) ?
    By teezee in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-08-2006, 07:15 PM
  7. What formula is used to add or subtract minutes from a time in a .
    By Lucky Phil in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-17-2005, 04:07 AM

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