+ Reply to Thread
Results 1 to 8 of 8

Formulas Involving Times In HH:MM Format - Why Is 2 Hours Not 2 Hours

  1. #1
    Registered User
    Join Date
    06-02-2023
    Location
    Newcastle, England
    MS-Off Ver
    Office 365
    Posts
    2

    Formulas Involving Times In HH:MM Format - Why Is 2 Hours Not 2 Hours

    Hi,

    I use an excel sheet whereby time charged to projects in decimal format (i.e 2.0 hours) is compared to time actually worked during the day (based on start and end times) in HH:MM format. This formula works 99.9% of the time but I have noticed an issue with times in general when the value is greater than 12 hours (12:00).

    So, for example if I input 2.0 hours to the sheet in decimal format against a project and then enter a start time of 11:00 and an end time of 13:00 for 2:00 hours total time this returns an actual figure of 0.083333333333333300000 which then compares to the total hours worked of 2 hours (2 hours/24 hours to get the decimal) = 0.0833333333333333000

    However, if I change the start and end times to 12:00 and 14:00 (which I believe should give exactly the same answer) this does not work as this returns an actual figure of 0.083333333333333400000 which then makes it appear that I have not charged the correct amount of time?

    Can anyone explain why this is and if there is anyway around it please?

    The sheet I have is set up to highlight if the time charged does not match the actual hours input which in the second example above it looks like it doesn't but in actual fact it does. As I say the issue seems to crop up where the time 12:00 is involved.

    Thanks,
    Mark

  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,931

    Re: Formulas Involving Times In HH:MM Format - Why Is 2 Hours Not 2 Hours

    Welcome to the forum.

    Some rounding will be required. Google 'floating point errors' to read all about this.

    If you want specific help, please provide a sample workbook.

    There are instructions at the top of the page explaining how to attach your sample workbook (yellow banner: HOW TO ATTACH YOUR SAMPLE WORKBOOK). Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    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
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Formulas Involving Times In HH:MM Format - Why Is 2 Hours Not 2 Hours

    This is almost certainly floating point rounding errors.

    See: https://en.m.wikipedia.org/wiki/Nume...icrosoft_Excel

    Use ROUND to help mitigate the issue.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Formulas Involving Times In HH:MM Format - Why Is 2 Hours Not 2 Hours

    If you calculate with times in Excel, rounding differences can occur.
    A well-known example is when you take the time off a date with mod 1.

    These rounding differences can be overcome by using the HOUR, MINUTE and SECOND or ROUND functions.
    Exactly how this is done depends on the situation.

  5. #5
    Registered User
    Join Date
    06-02-2023
    Location
    Newcastle, England
    MS-Off Ver
    Office 365
    Posts
    2

    Re: Formulas Involving Times In HH:MM Format - Why Is 2 Hours Not 2 Hours

    Thanks both, that has resolved the issue.

    Thanks again!

  6. #6
    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,931

    Re: Formulas Involving Times In HH:MM Format - Why Is 2 Hours Not 2 Hours

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  7. #7
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Formulas Involving Times In HH:MM Format - Why Is 2 Hours Not 2 Hours

    Glad to have helped.

    Thanks for the feedback and rep .

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Formulas Involving Times In HH:MM Format - Why Is 2 Hours Not 2 Hours

    You're welcome. Thanks for the rep.

+ 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. Finding Ship Times based on Hours of Shipper and Hours of Receiver
    By kmsagent in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-01-2019, 02:31 AM
  2. Replies: 3
    Last Post: 04-23-2016, 01:42 AM
  3. How many hours from total hours fall between certain times
    By sobek in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-15-2014, 10:51 AM
  4. [SOLVED] Formula involving times not working for specific hours, e.g. 22:00
    By kenle11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-07-2013, 11:51 PM
  5. Replies: 2
    Last Post: 03-02-2013, 10:57 AM
  6. [SOLVED] Formula to work out hours between 2 dates and times.. MINUS Out Of Hours
    By chris.m in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-30-2012, 08:11 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