+ Reply to Thread
Results 1 to 7 of 7

Round total time to 1 hour multiples with a minimum of two

  1. #1
    Forum Contributor
    Join Date
    01-05-2009
    Location
    South Dakota, USA
    MS-Off Ver
    2003, and 2007
    Posts
    150

    Round total time to 1 hour multiples with a minimum of two

    I need a basic formula that will take my start time from my end time and round it up to the next hour with a two hour minimum. I formated my cell to not have decimals and I tried to use round and roundup along with and if/then formula but no luck. If it makes any difference, all times are in 24hr format.

    Thanks
    Last edited by 2funny4words; 04-06-2009 at 03:03 PM.

  2. #2
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: Round total time to 1 hour multiples with a minimum of two

    Please Login or Register  to view this content.
    Something like that?
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Round total time to 1 hour multiples with a minimum of two

    This accomplishes the task without the double evaluation of an IF, and it converts the real TIME data in A1 an B1 into an integer:
    Please Login or Register  to view this content.
    =MAX(2,(B1-A1)*24)

    ...result in a normal "2" in this instance. Make sure the results cell is formatted as Number.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Contributor
    Join Date
    01-05-2009
    Location
    South Dakota, USA
    MS-Off Ver
    2003, and 2007
    Posts
    150

    Re: Round total time to 1 hour multiples with a minimum of two

    Quote Originally Posted by JBeaucaire View Post
    This accomplishes the task without the double evaluation of an IF, and it converts the real TIME data in A1 an B1 into an integer:
    Please Login or Register  to view this content.
    =MAX(2,(B1-A1)*24)

    ...result in a normal "2" in this instance. Make sure the results cell is formatted as Number.
    This is the one that I have tried so far since it is simpler, the only thing that I need to change is that I need to round the time up to the next hour even if I am just one minute into that hour.
    Also, (guess this makes two things, but....) sometimes my start time is say 23:38 and my end time is 03:54. What I would like to make possible is that the end user (a firefighter after a fire at three A.M.) does not have to add up and input 27:54 (which does give me what I need and also shows up as 03:54) but just makes things more difficult and prone to error.

    Thanks to both of you for your input

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Round total time to 1 hour multiples with a minimum of two

    No way I'm going to try and figure that out. Tell you what, mock a spreadsheet with some fake data in it and show ALL the situations that you need to cover. Put in start and end times and the preferred resulting calculation for each sample. Just do the math manually and explain it where needed.

    SHOW us what you're doing and all the variables therein, then we can help automate it.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Round total time to 1 hour multiples with a minimum of two

    You can use MOD to handle times that may/may not cross midnight:

    =MAX(2,ROUNDUP(24*MOD(B1-A1,1),0))

  7. #7
    Forum Contributor
    Join Date
    01-05-2009
    Location
    South Dakota, USA
    MS-Off Ver
    2003, and 2007
    Posts
    150

    Re: Round total time to 1 hour multiples with a minimum of two

    Thanks, that works just like I needed it to!

+ 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