+ Reply to Thread
Results 1 to 13 of 13

Making Time roll over after 24 hours

  1. #1
    Registered User
    Join Date
    11-25-2009
    Location
    Illinois
    MS-Off Ver
    Excel 2007
    Posts
    8

    Making Time roll over after 24 hours

    I'm creating a calculator to determine the distance & travel time on a xy grid for a game. I'll share what I have so far to display the big picture. Here’s what I’ve accomplished so far:

    #1) Cells A1 & B1 are dynamic, they are frequently changed so distance and time may be displayed. Cells A2 & B2 do not change.

    #2) I use the following formula to determine the distance between cells, displayed in C2: =SQRT((A2-$A$1)^2+(B2-$B$1)^2)

    #3) Next I multiply C2 by a number so that distance is measured correctly per unit type for this game. (I hide this column). Therefore, cell D3 has the following formula: =C2*20

    #4) Now my problem, cell E3 - Correctly displaying time. I have the following formula in E3: =TIME(0,D2,0)

    This works great!! That is until the time goes beyond 24 hours, then it rolls over. I've tried right clicking and setting the custom format of E3 to [hh]:mm, it still rolls over. I’ve also tried setting formatting to d:[hh]:mm, if I do this then the output time displayed is incorrect.

    Ideally I would love a simple fix so that the time will roll over and show days. (I would like a display similar to d:hh:mm).

    I’ve done a fair bit of research online and either I'm missing something simple or this is more complex than I thought. And not to make this any more confusing, but I would love whatever I accomplish here to be useable in compatibility mode.

    I am still learning excel and did not want to ask for help, but I seem to have ran into a road block. Please Help! Thanks in advance for your assistance.

    Regards,
    Emil240

    Example (this is accurate, but then A1&B1 are close enough where it does not roll over after 24 hours):
    59.........59.........Dist..........Unit.........Time
    68.........77.........20.12........402.5......06:42
    Last edited by Emil240; 11-26-2009 at 04:11 AM. Reason: disregard, everything was correct

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Making Time roll over after 24 hours

    Hi,

    Have you tried a custom format ...
    d - hh:mm:ss
    HTH

  3. #3
    Registered User
    Join Date
    11-25-2009
    Location
    Illinois
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Making Time roll over after 24 hours

    Thanks for the response JeanRage.

    I just tried that one as well, it's still rolling over, not displaying days.

    It displays "0 - hh:mm", but the day always stays at zero.

  4. #4
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Making Time roll over after 24 hours

    Since Excel saves Time as "portions of days" ... It sounds strange format does not work ..
    Would you mind posting a worksheet sample ...?

  5. #5
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Making Time roll over after 24 hours

    Hi,

    Attached is a sample ...

    HTH
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-25-2009
    Location
    Illinois
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Making Time roll over after 24 hours

    here's what i have...

    note the time should read 06:42. My goal is to have it read "1 - hh:mm" if greater than 24 hours. When I change the blue cells (A1 & A2), it just rolls over without the day.
    Attached Files Attached Files
    Last edited by Emil240; 11-26-2009 at 03:10 AM. Reason: updated for clarity

  7. #7
    Registered User
    Join Date
    11-25-2009
    Location
    Illinois
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Making Time roll over after 24 hours

    To be more specific, when I attempted the format suggested it also alters the time to "0 - 12:42". So not only is it not rolling over, it is also displaying the incorrect time.

    Here is my most recent example.

    Thanks in Advance,
    Siv
    Attached Files Attached Files
    Last edited by Emil240; 11-26-2009 at 03:23 AM. Reason: to be more specific

  8. #8
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Making Time roll over after 24 hours

    Not sure to understand the UNIT in your cell D2 ... ?
    Are we talking days ? or hours ? or minutes ?

  9. #9
    Registered User
    Join Date
    11-25-2009
    Location
    Illinois
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Making Time roll over after 24 hours

    D2 is the unit in the game. To be honest I don't fully understand why this works, but I know it does. By using that calculation it gives me the exact time in game.

    I wish I could be more specific. I learned this from trial and error. What is important is that the time in E2 reads "06:42" when the value of the blue cells are 59,59.

  10. #10
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Making Time roll over after 24 hours

    Take a look at attached sample ...
    Let me know if it is OK ...

    HTH
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    11-25-2009
    Location
    Illinois
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Making Time roll over after 24 hours

    Works like a charm. You help is very much appreciated! I spent a long time trying to figure this out to no avail & now very glad I posted. It would have taken me quite some to find that fix.

    Issue solved.

    Thank you very much!

    Best wishes,
    Emil240

    (Emil240 shares some cookies and brownies as a thank you gift)

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

    Re: Making Time roll over after 24 hours

    To clarify why Jean Rage's will work and yours did not...

    TIME in XL is Decimal, eg noon = 0.5, 6 am = 0.25 and 6pm = 0.75

    The above is important to note because the TIME function will only work with the decimal time value (ie complete days (integer) will be ignored)... to quote XL Help:

    TIME FUNCTION

    Returns the decimal number for a particular time

    The decimal number returned by TIME is a value ranging from 0 (zero) to 0.99999999, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.).
    So to elaborate with ex. - if D2 is say 360 then both

    =TIME(0,D2,0)

    and

    =D2/1440

    will return 0 06:00
    ie 360 minutes is 06:00 hours - in decimal terms 0.25

    However if D2 were say 1800 then

    =TIME(0,D2,0)

    would still return 0 06:00

    whereas

    =D2/1440

    would return 1 01:00

    This is because TIME will only work with decimal remainder... the value of 1800 minutes is in XL terms 1.25 - 1 and a quarter days... TIME will use only the .25 in it's calculation thus returning just 0 06:00. The D2/1440 approach will not disregard the complete days.

  13. #13
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Making Time roll over after 24 hours

    Glad you could fix your problem ...

    Happy Thanksgiving ...

+ 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