Excel Formula

%3CLINGO-SUB%20id%3D%22lingo-sub-1609316%22%20slang%3D%22en-US%22%3EExcel%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1609316%22%20slang%3D%22en-US%22%3E%3CP%3EI%20need%20to%20make%20a%20formula%20that%20will%20calculate%20the%20days%20beetween%20two%20dates%20if%20there%20is%20a%20date%20in%20the%20selected%20cell.%20If%20there%20is%20not%20a%20date%20in%20the%20selected%20cell%2C%20then%20I%20would%20like%20it%20to%20calculate%20it%20from%20one%20date%20to%20today.%26nbsp%3BThis%20is%20the%20formula%20I%20have%20so%20far%20that%20I%20tried%20to%20use%20%3DIF(NOT(ISBLANK(AB5))%2C%22%3DDATEDIF(AA5%2CAB5%2C%22d%22)%22%2C%22%3DDATEDIF(AA5%2CTODAY()%2C%22d%22)%22).%3C%2FP%3E%3CP%3EWhen%20I%20put%20this%20formula%20in%2C%20excel%20seems%20to%20have%20an%20issue%20with%20%22d%22%20but%20if%20I%20remove%20that%2C%20then%20it%20will%20enter%20%22%3DDATEDIF(AA5%2CAB5%22)%22%20or%20%22%3DDATEDIF(AA5%2CTODAY()%22%20in%20the%20cell.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20new%20to%20the%20%22IF%22%20function%20in%20excel%20so%20I%20could%20use%20some%20help%20on%20this.%20I've%20also%20never%20tried%20to%20do%20a%20formula%20in%20another%20formula.%20Any%20help%20would%20be%20appreciated.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1609316%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1609727%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1609727%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F769550%22%20target%3D%22_blank%22%3E%40Rachel1910%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20it%20like%20this...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DIF(NOT(ISBLANK(AB5))%2CDATEDIF(AA5%2CAB5%2C%22d%22)%2CDATEDIF(AA5%2CTODAY()%2C%22d%22))%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1609732%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1609732%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F769550%22%20target%3D%22_blank%22%3E%40Rachel1910%3C%2FA%3E%26nbsp%3BAs%20a%20variant%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(ISNUMBER(AB5)%2CAB5-AA5%2CTODAY()-AA5)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1609792%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1609792%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F769550%22%20target%3D%22_blank%22%3E%40Rachel1910%3C%2FA%3E%2C%20another%20variant%20would%20be%3A%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(N(AB5)%2CAB5%2CTODAY())-AA5%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Visitor

I need to make a formula that will calculate the days beetween two dates if there is a date in the selected cell. If there is not a date in the selected cell, then I would like it to calculate it from one date to today. This is the formula I have so far that I tried to use =IF(NOT(ISBLANK(AB5)),"=DATEDIF(AA5,AB5,"d")","=DATEDIF(AA5,TODAY(),"d")").

When I put this formula in, excel seems to have an issue with "d" but if I remove that, then it will enter "=DATEDIF(AA5,AB5")" or "=DATEDIF(AA5,TODAY()" in the cell. 

I am new to the "IF" function in excel so I could use some help on this. I've also never tried to do a formula in another formula. Any help would be appreciated. 

3 Replies

@Rachel1910 

Try it like this...

 

=IF(NOT(ISBLANK(AB5)),DATEDIF(AA5,AB5,"d"),DATEDIF(AA5,TODAY(),"d"))

@Rachel1910 As a variant:

=IF(ISNUMBER(AB5),AB5-AA5,TODAY()-AA5)

 

@Rachel1910, another variant would be: 

=IF(N(AB5),AB5,TODAY())-AA5