Forum Discussion

JennyBee's avatar
JennyBee
Copper Contributor
Aug 21, 2024

Number of days + or -

I am trying to get the difference in the number of days between two dates and it works if the target completion date is before the completion date using this formula: =DATEDIF(H3,J3,"d"). I do get the correct number of days using this formula, however, I would ideally like is a plus or minus in front of that number (e.g., + if the project went past the target date, and - if the project was completed sooner). I can apply conditional formatting to the rows after to change the color of the number if I get that far.

 

When the completion date is before the target completion date (e.g., completed project early), I get the #NUM! error, which I expected. But I cannot find a way to get exactly what I am looking for. Hopefully I am explaining this clearly. The formula in L4: =DATEDIF(H4,J4,"d")

 

 

 

 

 

 

  • SnowMan55's avatar
    SnowMan55
    Bronze Contributor
    With Excel's default date settings (the "1900 date system"), Excel dates are internally represented as the number of days since (approximately) 1 Jan 1900. So you can simply subtract one date from another to get the difference (positive, negative, or zero).
    • JennyBee's avatar
      JennyBee
      Copper Contributor
      Thank you. Simple I will try that tomorrow.
      • SnowMan55's avatar
        SnowMan55
        Bronze Contributor
        Oh, I should have mentioned... Excel will by default format the cell containing the subtraction formula as a Date. Just change that format to General (or Number, if you prefer).

Resources