简体   繁体   中英

Datedif and If statement in Excel

I want to create an Excel formula that allows me to calculate the datedif of the month (ie Date of Expiry - Today's Date). Which I have done as seen below:

在此处输入图片说明

This is my formula:

=IFERROR(DATEDIF($F$1,C4,"m") & " Months", "Already Expired")

However, I want a formula that can take note of the (s) in Months if the months left is only 1 Month. (Ie I do not want the s behind the Months if the "m" in datedif is just 1 month difference.) How do I achieve that?

I would write the unit into the cell format, not the formula. The formula should produce an integer and the cell format should be Custom [=1]0 "month";0 "months" .

To test, format a cell as described above and enter any number. The cell will display the number and the word "moth" or "months", depending upon the value you entered.

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