简体   繁体   中英

Excel - Want to compare a projected date against a target date

In Excel, I am trying to compare a forecast date against a target date and state in the 3rd column the difference, I have searched for a formula to put in the 3rd column such as DATEDIF (F5, G5,"m") but this is not able to state the difference if the projected date is less than the target date,

Please see example below:

EXCHANGE Target Date EXCHANGE Forecast Date EXCHANGE Difference 01/12/2018 11/01/2019 1 01/08/2017 16/02/2019 18 02/08/2017 01/06/2017 #NUM!

Use some Error handling, if the date is in the past, flip the calculation and multiply it by -1 or subtract it from 0. It's annoying that the function doesn't handle this itself but oh well...

IFERROR(DATEDIF(F5,G5,"m"),DATEDIF(G5,F5,"m")*-1)

IFERROR(DATEDIF(F5,G5,"m"),0-DATEDIF(G5,F5,"m"))

EDIT:

To evaluate weeks you would use the same function but taking the difference in days, you can then divide the result by 7 (make use of the ROUND() function if you don't want a decimal answer)

IFERROR(DATEDIF(F5,G5,"D")/7,0-DATEDIF(G5,F5,"D")/7)

IFERROR(ROUND(DATEDIF(F5,G5,"D")/7,0),ROUND(0-DATEDIF(G5,F5,"D")/7,0))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM