Forum Discussion

raczoliver's avatar
raczoliver
Copper Contributor
Sep 30, 2023
Solved

Formula occasionally returning 0:00 and -0:00 instead of blank

Hello! I am trying to subtract the time in column W from the time in column H, and enter the result into a third column. The time in column H is always greater than or equal to the time in colum W, a...
  • JoeUser2004's avatar
    JoeUser2004
    Oct 01, 2023

    raczoliver  wrote:  ``I figured out the -0:00s are there because I enabled the use of 1904 date system``

     

    Oh yes, I forgot about that.  I hope you stop doing that.  It can cause problems if you copy data from one workbook to another.

     

    EDIT....  Unless you use a Mac, in which case I've read that 1904 is the default date system.

     

    -----

    raczoliver  wrote:  ``I suppose these few examples should be enough to troubleshoot my problem``

     

    See the image below and the "corrected" worksheet in the attached Excel file for details.

     

     

    Apparently, the values in column A, B and E are the results of unrounded calculations, which you copy-and-pasted-value into the example Excel file.

     

    This causes infinitesimal differences between the displayed time and the actual binary value. 

     

    That is demonstrated by the formulas that are highlighted in "red" (pink) in columns G, H and K.  For example:

     

    G1: =SUM(A1, -TEXT(A1,"[h]:m"))

     

    (I use SUM instead of simply =A1 - TEXT(A1,"[h]:m") in order to avoid a misleading "feature" of Excel arithmetic in the latter form.)

     

    Each of the original formulas in those cells should be explicitly rounded to the minute.  For example:

     

    A10: =--TEXT(A1, "[h]:m")

    B10: =--TEXT(B1, "[h]:m")

    E10: =--TEXT(E1, "[h]:m")

     

    Of course, where I reference a cell (A1), you would use that formula in A1 itself, replacing the formula =expression with =--TEXT(expression, "[h]:m").

     

    The original formulas in column C can be simplified.  For example:

     

    C10: =IF(A10=B10, "", --TEXT(B10-A10+(B10<A10), "[h]:m"))

     

    Then, the formulas in column D can be, for example:

     

    D10: =IF(C10<=E10, "", --TEXT(C10-E10, "[h]:m"))

     

Resources