Assistance Needed with Excel Formula

JanaP73

New Member
Joined
Mar 28, 2025
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm struggling to find an Excel formula for the following scenario:

- If the enrollment date is greater than 6 months but less than 2 years and 1 month, the output should be "OK."
- If the enrollment date is greater than 2 years and 1 month but less than 4 years, the output should be "No."
- If the enrollment date is greater than 4 years, the output should be "Perfect."

Could you help me with this? Thank you!
 
Enrollment date is compared to today's date or anything else.
A small data with expected result in XL2BB format makes easy to solve the problem. Pl post data.
 
Upvote 0
Welcome to the forum JanaP73,

Maybe the DATEDIF function will get you started, it returns the difference between two dates in a unit of your choice, months in your example. In the below example it compares dates to todays date and returns that difference in months as a whole number.

Book1
ABC
1Enrollment DateDifference to today in months
201/01/2010182
301/01/202414
401/01/202326
528/01/20252
6
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=DATEDIF(A2,TODAY(),"M")
 
Upvote 0
Enrollment date is compared to today's date or anything else.
A small data with expected result in XL2BB format makes easy to solve the problem. Pl post data.
I apologise for not mentioning earlier that the enrollment date is compared to today's date
Thank you
Welcome to the forum JanaP73,

Maybe the DATEDIF function will get you started, it returns the difference between two dates in a unit of your choice, months in your example. In the below example it compares dates to todays date and returns that difference in months as a whole number.

Book1
ABC
1Enrollment DateDifference to today in months
201/01/2010182
301/01/202414
401/01/202326
528/01/20252
6
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=DATEDIF(A2,TODAY(),"M")
 
Upvote 0
Hi Georgiboy,

Thank you for your suggestion. I tried that, but it is still not working. I have uploaded the spreadsheet I'm working on. Please see if you can fix it. Thank you.
 

Attachments

  • TEST.png
    TEST.png
    35.1 KB · Views: 12
Upvote 0
I am confused now, it looks like you are trying to do something different from the original request?

Are you trying to create a text string with years, months and days different between a date in column A and todays date?
 
Upvote 0
See if the below helps:
Cell Formulas
RangeFormula
B3:B18B3=EDATE(A3,6)
C3:C18C3=LET(d,A3,t,TODAY(),DATEDIF(d,t,"Y")&" years, "&DATEDIF(d,t,"YM")&" months, "&DATEDIF(d,t,"MD")&" days")
D3:D18D3=LET(dd,DATEDIF(A3,TODAY(),"M"),IF(dd>=48,"Perfect",IF(AND(dd<48,dd>25),"No",IF(AND(dd<=25,dd>=6),"OK",""))))
 
Upvote 0
Timesheet.xlsm
ABCD
1DateFormulaYrs,Mths,Days
229-09-2024 0y,5m,27d
327-09-2024OK0y,6m,1d
401-10-2022NO2y,5m,27d
529-03-2021NO3y,11m,27d
630-03-2021NO3y,11m,26d
704-03-2021PERFECT4y,0m,24d
8
Sheet2
Cell Formulas
RangeFormula
B2:B7B2=IF(A2="","",IF((DATEDIF(A2,TODAY(),"Y")*12+ DATEDIF(A2,TODAY(),"YM")+(DATEDIF(A2,TODAY(),"MD")>0))<=6,"",IF((DATEDIF(A2,TODAY(),"Y")*12+ DATEDIF(A2,TODAY(),"YM")+(DATEDIF(A2,TODAY(),"MD")>0))<=25,"OK",IF((DATEDIF(A2,TODAY(),"Y")*12+ DATEDIF(A2,TODAY(),"YM")+ (DATEDIF(A2,TODAY(),"MD")>0))<=48,"NO","PERFECT"))))
C2:C7C2=+DATEDIF(A2,TODAY(),"Y")&"y,"& DATEDIF(A2,TODAY(),"YM")&"m,"& DATEDIF(A2,TODAY(),"MD")&"d"

For other than 365 version.
In B2 copied down
Excel Formula:
=IF(A2="","",IF((DATEDIF(A2,TODAY(),"Y")*12+ DATEDIF(A2,TODAY(),"YM")+(DATEDIF(A2,TODAY(),"MD")>0))<=6,"",IF((DATEDIF(A2,TODAY(),"Y")*12+ DATEDIF(A2,TODAY(),"YM")+(DATEDIF(A2,TODAY(),"MD")>0))<=25,"OK",IF((DATEDIF(A2,TODAY(),"Y")*12+ DATEDIF(A2,TODAY(),"YM")+ (DATEDIF(A2,TODAY(),"MD")>0))<=48,"NO","PERFECT"))))
In C2 copied down
Excel Formula:
=DATEDIF(A2,TODAY(),"Y")&"y,"& DATEDIF(A2,TODAY(),"YM")&"m,"& DATEDIF(A2,TODAY(),"MD")&"d"

For 365 version.
In B2
Excel Formula:
=LET(a,A2:A7,yrm,DATEDIF(a,TODAY(),"Y")*12,mns,DATEDIF(a,TODAY(),"YM"),dys,DATEDIF(a,TODAY(),"MD")>0,MAP(a,yrm,mns,dys,LAMBDA(xa,xy,xm,xd,IF(xa="","",IF((xy+xm+xd)<=6,"",IF((xy+xm+xd)<=25,"OK",IF((xy+xm+xd)<=48,"NO","PERFECT")))))))
In C2
Excel Formula:
=LET(a,A2:A7,DATEDIF(a,TODAY(),"Y")&"y,"& DATEDIF(a,TODAY(),"YM")&"m,"& DATEDIF(a,TODAY(),"MD")&"d")
 
Upvote 0

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