+ Reply to Thread
Results 1 to 18 of 18

Need help calculating hours and minutes in a rolling 24 hour period with "If/Then" also

Hybrid View

  1. #1
    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
    53,050

    Re: Need help calculating hours and minutes in a rolling 24 hour period with "If/Then" als

    Hi and welcome to the forum

    1 thing to remember about working with time in excel, is that excel treats time as a fraction/decimal of 1. So 6am is actually 0.25, 12 noon is 0.5 etc. So if you are working with time that goes from 1 day to the next, you need to subtract the start time from 1.00 and then the end time (in simple terms)
    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

  2. #2
    Registered User
    Join Date
    06-08-2013
    Location
    Greenwood, DE
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Need help calculating hours and minutes in a rolling 24 hour period with "If/Then" als

    Can you give me an example? Start at 23:42 on day one and end at 3:08 on day 2 . . . on my fingers its 3.5 hours, but I want Excel to tell me that.

  3. #3
    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
    53,050

    Re: Need help calculating hours and minutes in a rolling 24 hour period with "If/Then" als

    To test for the today-tomorrow situation...
    =IF(A1>B1,(1-A1)+B1,B1-A1)

    So if you swap those times around, you would get 20:34 20 hours 34 minutes

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,434

    Re: Need help calculating hours and minutes in a rolling 24 hour period with "If/Then" als

    Assume 23:42 is in A1 and 3:08 in B1 - put this formula in C1:

    =B1-A1+(A1>B1)

    Format the cell as time, and you should see 3:26 - not sure why you think it should be 3.5, but if you want to see the result in hours, then you can do this:

    =(B1-A1+(A1>B1))*24

    and format the cell as General or Number - you should see 3.43333.

    Hope this helps.

    Pete

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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