+ Reply to Thread
Results 1 to 5 of 5

Subtracting Times

  1. #1
    Registered User
    Join Date
    05-28-2009
    Location
    Oxford
    MS-Off Ver
    Excel 2007
    Posts
    86

    Subtracting Times

    I am making a timesheet but having trouble with subtracting times.

    I have subtracted 3 times away (start time / lunch break / end time) to calculate hours worked.

    I have then taken this from the Contracted hours to see + / - time worked.

    However when you look at the calculation of the + / - time worked as a number, there is a a variance at the 16th number past the decimal point when they should be exactly the same (for 07:35 - 07:35). This causes the timesheet to display + and - values for 00:00.

    Please see attached excel file on the Example sheet dates 26/01/2011 to 27/01/2011. I have no idea why there is this discrepancy.

    Many thanks.
    Attached Files Attached Files
    Last edited by Knawl; 11-02-2010 at 03:51 AM.

  2. #2
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: Subtracting Times

    Why do you require it to display anything if it should be resulting in 0? can you not just substitute 0 for ""
    Windows 7 using Office 2007 & 2010

    Remember your [ code ] [ /code ] tags, makes reading soooo much easier

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Subtracting Times

    I have no idea why there is this discrepancy.
    The reason for the discrepancy is because computers (this is not Excel specific) perform calculations in binary while we use decimals and transferring back and forth can lead to discrepancies out around the 15th decimal. You could get around it by using the ROUND function at specific points.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Subtracting Times

    Quote Originally Posted by ChemistB View Post
    The reason for the discrepancy is because computers (this is not Excel specific) perform calculations in binary while we use decimals and transferring back and forth can lead to discrepancies out around the 15th decimal. You could get around it by using the ROUND function at specific points.
    you could just round

    =round((a1-b1)*86400,0)/86400 which will round to the nearest second

    or round((a1-b1)*1440,0)/1440 which will round to the nearest minute!

    Should solve your problem
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  5. #5
    Registered User
    Join Date
    05-28-2009
    Location
    Oxford
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: Subtracting Times

    Quote Originally Posted by squiggler47 View Post
    you could just round

    =round((a1-b1)*86400,0)/86400 which will round to the nearest second

    or round((a1-b1)*1440,0)/1440 which will round to the nearest minute!

    Should solve your problem

    That's great thanks. I just used =IF(I38+J38<=0,ROUND((G38-F38)*86400,0)/86400,0).

+ 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