excel syntax problem for formula... difference in days


  1. Posts : 278
    7600x64 ultimate, not SP1
       #1

    excel syntax problem for formula... difference in days


    if I have 2 columns of dates and I want to find the number of days between the days of D2 and C2, what is the syntax for the formula so that the result in column E is x number of days between the two dates
      My Computer


  2. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #2

    Format the columns as follows:

    Columns C and D as Date (you choose the specific date format).
    Column E as Number (with 0 Decimal places).

    The formula to use in Column E to give the difference in days is as follows (assuming that C is an earlier date than D):

    E=D-C (E2=D2-C2)

    If you want the number of days between, but not counting either day, then the formula is:

    E=D-C-1 (E2=D2-C2-1)

    If, on the other hand, you want to know the inclusive number of days, the formula is:

    E=D-C+1 (E2=D2-C2+1)

    Note that the above may yield negative results. To avoid that, use these modified formulae instead:

    E=ABS(D-C) (E2=ABS(D2-C2))
    E=ABS(D-C)-1 (E2=ABS(D2-C2)-1)
    E=ABS(D-C)+1 (E2=ABS(D2-C2)+1)
      My Computer


  3. Posts : 278
    7600x64 ultimate, not SP1
    Thread Starter
       #3

    Thank you, I didn't realize I could subtract dates like that.
      My Computer


  4. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #4

    You're welcome. Incidentally, if the dates happen to be the same (which is unlikely, but cannot be totally ruled out), then the following minor alteration to the relative formulae will take care of it (and are the versions that I recommend).

    E2=IF((D2==C2),0,ABS(D2-C2))
    E2=IF((D2==C2),0,ABS(D2-C2)-1)
    E2=IF((D2==C2),0,ABS(D2-C2)+1)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:53.
Find Us