Datedif not working HELP

SamBT

New Member
Joined
Feb 11, 2023
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
i am using this formula on MS Teams and it is giving me an answer of 1 Yr 11mnths instead of 2 yrs 0 months can any one tell me why - the dates is 01/04/2020 to 31/01/2022
=IF(AND(ISBLANK(DV89); ISBLANK(DW89)); ""; IF(OR(ISBLANK(DV89); ISBLANK(DW89)); "PERIOD UNKNOWN"; IF(OR(ISERROR(DV89); ISERROR(DW89)); "FIX DATE"; DATEDIF(DV89; DW89; "Y") + IF(DAY(DW89) >= DAY(DV89); 0; -1) & " YRS " & MOD(DATEDIF(DV89; DW89; "M"); 12) + IF(DAY(DW89) >= DAY(DV89); 0; 1) & " MTHS")))
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
The example you gave actually generates 1 yr 9 mths not 1 yr 11 mths. Its a question of interpretation. DateDif is using the concept of Anniversary date. The year does not click over until the anniversary date so in your case the anniversary date is 01/04/2022 not 31/03/2022. If you want to do what you seem to be expecting just subtract 1 day from the start date or add 1 day to the end date (make sure you do the same to both the Year and the Month calculations)
PS: for the months you should have been able to use DATEDIF(DV89; DW89; "YM")
 
Upvote 0
Hi thank you is there perhaps another formula I can use I added +1 into the formula and it is still giving me the same answer 1 YRS 11 MTHS:( if I add +2 it changes to 1 YRS 0 MNTHS
 
Upvote 0
I am using your formula and that is not what I am getting:

20241129 DateDif Years and Months SamBT.xlsx
ABCDUDVDW
88Original Formula=DATEDIF(DV89,DW89,"Y")=DATEDIF(DV89,DW89,"YM")StartEnd
891 YRS 9 MTHS191/04/202031/01/2022
902 YRS 0 MTHS201/04/20201/04/2022
Sheet1
Cell Formulas
RangeFormula
B88:C88B88=FORMULATEXT(B89)
A89:A90A89=IF(AND(ISBLANK(DV89), ISBLANK(DW89)), "", IF(OR(ISBLANK(DV89), ISBLANK(DW89)), "PERIOD UNKNOWN", IF(OR(ISERROR(DV89), ISERROR(DW89)), "FIX DATE", DATEDIF(DV89, DW89, "Y") + IF(DAY(DW89) >= DAY(DV89), 0, -1) & " YRS " & MOD(DATEDIF(DV89, DW89, "M"), 12) + IF(DAY(DW89) >= DAY(DV89), 0, 1) & " MTHS")))
B89:B90B89=DATEDIF(DV89,DW89,"Y")
C89:C90C89=DATEDIF(DV89,DW89,"YM")
 
Upvote 0
This has an alternative with the additional day factored in:
20241129 DateDif Years and Months SamBT.xlsx
ABCDUDVDW
88Original FormulaAlternative formula (with additional day added)StartEnd
891 YRS 9 MTHS1 YRS 10 MTHS1/04/202031/01/2022
902 YRS 0 MTHS2 YRS 0 MTHS1/04/20201/04/2022
911 YRS 11 MTHS2 YRS 0 MTHS1/04/202031/03/2022
Sheet1
Cell Formulas
RangeFormula
A89:A91A89=IF(AND(ISBLANK(DV89), ISBLANK(DW89)), "", IF(OR(ISBLANK(DV89), ISBLANK(DW89)), "PERIOD UNKNOWN", IF(OR(ISERROR(DV89), ISERROR(DW89)), "FIX DATE", DATEDIF(DV89, DW89, "Y") + IF(DAY(DW89) >= DAY(DV89), 0, -1) & " YRS " & MOD(DATEDIF(DV89, DW89, "M"), 12) + IF(DAY(DW89) >= DAY(DV89), 0, 1) & " MTHS")))
B89:B91B89=IF(AND(ISBLANK(DV89), ISBLANK(DW89)), "", IF(OR(ISBLANK(DV89), ISBLANK(DW89)), "PERIOD UNKNOWN", IF(OR(ISERROR(DV89), ISERROR(DW89)), "FIX DATE", DATEDIF(DV89, DW89+1, "Y") & " YRS " & DATEDIF(DV89, DW89+1, "YM") & " MTHS")))
 
Upvote 0
Solution
You are an absolute genius. Thank you so much for helping me the +1 helped. Thank you very much.
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,463
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top