+ Reply to Thread
Results 1 to 22 of 22

Time formulas are acting wonky

  1. #1
    Registered User
    Join Date
    08-14-2018
    Location
    California
    MS-Off Ver
    2010
    Posts
    8

    Time formulas are acting wonky

    Hello all,

    I am having one heck of a time figuring out why I am running into issues with these relatively basic time cells. So I have made a fuel calclator for our flights in the F-18. It builds a "fuel ladder" starting from our land time working backwards every 15 minutes =F10-TIME(0,15,0) with the associated fuel state you should be at next to it. I have some conditional formatting to make the cells turn green if the time matches your Takeoff time inputted on another cell, as well as a formula that will add gas to the state if the time matches an airborne refueling time also entered on another cell. The conditional formatting and the formulas all work fine except for a few of the rows. For the life of me I cannot figure it out as they have idential formulas and are all formatted in the same way. If I manually enter the time directly in the cell (eg. D4=14:00 vice D4=D5+TIME(0,15,0) it will work! Again, this is only on specific times and not the specific cells.

    I have made a simple test without most of the funtionality of my working document and running into the same issue. For whatever reason the highlighted times are not showing up as matching their adjacent manually entered time on the left. Ref. images

    Any help is greatly appreciated!

    Thank you!!!
    TEST_CELL.jpg
    TEST_CELL2.jpg
    TEST_CELL3.jpg
    TEST_CELL4.jpg

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    re: Time formulas are acting wonky

    Have you checked the time in column D? It's probably showing as 12:30:00 while then in in column F is 12:30 (text and not a real time value).
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    08-14-2018
    Location
    California
    MS-Off Ver
    2010
    Posts
    8

    re: Time formulas are acting wonky

    Yes, all are formatted as time 00:00 as shown here:
    FORMAT.jpg

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    re: Time formulas are acting wonky

    Are both columns time only, or date and time formatted as time?

    A bit of overkill, but see if this works correctly?

    =IF(MOD(F6,1)=MOD(D6,1),"WORK","NO WORK")

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    re: Time formulas are acting wonky

    Another simple comparison in colum E place the formula =D5=F5 you'll notice right away

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Time formulas are acting wonky

    You fell for the same misconception as do many Excel users.
    What you see in a cell (when it's formatted) is the formatted result, so if I place 23.668 in a cell and format is as 0.00 the value you SEE is 23.69 so if you enter 23.69 in the cell next to it and us use conditional formatting to color the cell if the value is equal to the other one it is not. because 23.69 is NOT equal to 23.688

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,415

    Re: Time formulas are acting wonky

    In addition to the rounding "error" that Keebellah notes, there is also the potential for "floating point" error when dealing with times (especially calculated times). Remember that, to Excel, time is just a floating point double precision number between 0 and 1, which means that it is subject to floating point errors. You may need to consider this possibility and adjust your algorithm to account for these errors (usually some kind of ROUND() function).

    More than you probably ever wanted to know about floating point errors: https://www.excelforum.com/groups/ma...nd-errors.html
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  8. #8
    Registered User
    Join Date
    08-14-2018
    Location
    California
    MS-Off Ver
    2010
    Posts
    8

    Re: Time formulas are acting wonky

    Here is the =D5=F5 comparison, same issue. jason.b75, no difference with MOD. WTF!!!!????

    testnew.jpg

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Time formulas are acting wonky

    It seems nobody is listening.
    Good-night then
    It's bed-time here

  10. #10
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Time formulas are acting wonky

    In that case, it is floating point precision, I tried the test with times entered directly into D6:D20, and calculated times in F6:F20 and had more FALSE resuluts than your example, (I have seen a time formula issue previously where the formula worked for me, but not for the member I was replying to, we isolated the cause to differences in reginal settings ).

    Try

    =IF(AND(HOUR(F6)=HOUR(D6),MINUTE(F6)=MINUTE(D6)),"WORK","NO WORK")

    That should eliminate any rounding issues, if you need precision to include seconds as well then that can easily be added to the formula.

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Time formulas are acting wonky

    This should be easy enough to sort out. Can you post a workbook so we can take a look?

    The forum rules explain how.
    Entia non sunt multiplicanda sine necessitate

  12. #12
    Registered User
    Join Date
    08-14-2018
    Location
    California
    MS-Off Ver
    2010
    Posts
    8

    Re: Time formulas are acting wonky

    Keeballah,

    Saw your post after I posted mine. I understand the rounding error, but I do not see how that is the case when all cells are formatted for TIME 00:00 and times have only been entered in 00:00 format never refrencing seconds. My gut is telling me it is a floating point error, now time to read up on this!

  13. #13
    Registered User
    Join Date
    08-14-2018
    Location
    California
    MS-Off Ver
    2010
    Posts
    8

    Re: Time formulas are acting wonky

    Here is the test sheet I'm using to figure this out.
    Attached Files Attached Files

  14. #14
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,415

    Re: Time formulas are acting wonky

    Definitely looks like floating point error. I formatted your time cells as "0.00000000000000000" instead of time and expanded the columns so I could see all digits. Sure enough, in all "no work" cases, there was a difference in the last digit/bit. As I noted, the usual solution is to use a ROUND() function IF(ROUND(D4,6)=ROUND(F4,6),...) or an ABS(difference) test IF(ABS(D4-F4)<1E-6,...) or some other strategy that will capture and ignore this insignificant difference.

  15. #15
    Registered User
    Join Date
    08-14-2018
    Location
    California
    MS-Off Ver
    2010
    Posts
    8

    Re: Time formulas are acting wonky

    MrShorty,

    Looks like that fixed the issue. Seems odd to have to do this though! I'll try to implement this into the working doc and see if it fixes my issues!

    Thank you!

  16. #16
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Time formulas are acting wonky

    I added conditional formatting with the way I see it and your MOD formula
    I've run into this so many time.
    NOW I'm off to bed.
    Bye for now.
    Attached Files Attached Files

  17. #17
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,415

    Re: Time formulas are acting wonky

    If it seems odd to you, then be sure to review some of those links about floating point issues. This is and has been a universal issue for computers doing arithmetic since the beginning, and will continue to be a part of computer arithmetic. If you are going to be doing these kinds of calculations, you need to be aware of how floating point issues can impact the calculations and how to work around them.

  18. #18
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Time formulas are acting wonky

    I'm quiet aware of floating point issues but this is a check of difference in tow time values which are hh mm ss and if you compare an entered value manually Excel automatically makes it hh:mm:ss even IF you enter only the hours and the minutes.
    The other column is a result and does NOT contain a seconds value, maybe 01 second so 12:30:00 IS different to 12:30:01.9999 or whatever and the OP is staring blind at the FORMAT of the cell not the value.
    So that is all I did in the conditional formatting.
    This will not be resolved by the floating point issue or whatever and the floating point issue is of severe importance to critical calculations as flight plans or measurements but the comparison for a visual difference has nothing to do with that.

  19. #19
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Time formulas are acting wonky

    If you change F6 to

    =MROUND(F7 - "0:15", "0:01")

    it works fine.

    You fly out of Lemoore?

  20. #20
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Time formulas are acting wonky

    Time formats and all the same as goes for values
    Attached Images Attached Images
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    08-14-2018
    Location
    California
    MS-Off Ver
    2010
    Posts
    8

    Re: Time formulas are acting wonky

    Thanks all! I think this should solve the issue and learned about floating points along the way. I think the ROUND/MROUND will be the easiest method to get around this. Much appreciated! shg, that's affirm.....Lemoore alright! Spent some time in TX during training

  22. #22
    Registered User
    Join Date
    08-14-2018
    Location
    California
    MS-Off Ver
    2010
    Posts
    8

    Re: Time formulas are acting wonky

    Thanks Kee,

    This helps a lot with my understanding of how it works. Much appreciated!

+ 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. Wonky XIRR Return
    By Drymr in forum Excel General
    Replies: 14
    Last Post: 12-27-2017, 09:20 PM
  2. Replies: 1
    Last Post: 11-14-2017, 11:44 AM
  3. Replies: 4
    Last Post: 01-17-2017, 12:58 PM
  4. Data in Excel 2010 Gets Wonky
    By npaprocki in forum Excel General
    Replies: 1
    Last Post: 01-03-2015, 10:16 AM
  5. [SOLVED] Microsoft Time and Date Picker Control SP6 acting up
    By bibu in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-16-2014, 12:24 PM
  6. Plots get all "wonky" when I try to print??? Have no clue why...
    By mhouston in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-14-2013, 10:45 PM
  7. Acting on Real time data feed
    By Paul987 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-15-2006, 10:50 AM

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