简体   繁体   English

Excel-想要比较预计日期与目标日期

[英]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, 在Excel中,我试图将预测日期与目标日期进行比较,并在第三列中说明差异,我已经搜索了要放在第三列中的公式,例如DATEDIF(F5,G5,“ m”),但是如果预计日期小于目标日期,则无法说明差异,

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! 交换目标日期交换预测日期交换差异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... 使用一些错误处理,如果日期是过去的日期,则将计算结果翻转并乘以-1或从0中减去。令人烦恼的是,该函数本身无法处理此问题,但是好吧...

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) 要评估周数,您将使用相同的函数,但以天为单位进行计算,然后可以将结果除以7(如果您不希望使用十进制答案,请使用ROUND()函数)

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))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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