Reputation: 111
I'm working on displaying a specific text in a cell based on a date value in another cell.
Scenario:
On Cell A2 = this is where the date in inputed
On cell B2 = this counts the date difference and display it on year and month and days
On cell C2 = this should display a specific text/value based on Cell B2.
I have this written on cell B2 :
=IF(DATEDIF(A2,today(),"y")=0, "", DATEDIF(A2,today(),"y") & " years ") & IF(DATEDIF(A2,today(),"ym")=0,"", DATEDIF(A2,today(),"ym") & " months ") & IF(DATEDIF(A2, today(), "md")=0, "", DATEDIF(A2, today(), "md") & " days")
Its output is formatted to display (e.g 1year 2months 3days). Now what I want to do is to display specific value on cell C2 based on the output from B2. This is the value and ranges:
If cell B2 = 1day - 3months this should display "Tadpole"
If cell B2 = 3months and 1 day - 6months this should display "young frog"
If cell B2 = 6months and 1day - 1year this should display "mature frog"
If cell B2 = 1year and 1 day - onwards this should display "Old Frog"
I have this code to display specific text, but it doesn't work well in this scenario:
=IF(B2="","",IF(AND(B2>=0,B2<=3),"Tadpole"
Sample Output:
Upvotes: 1
Views: 1969
Reputation: 1240
Here is the formula you want =IF(OR(AND(DATEDIF(A2,TODAY(),"y")=0,DATEDIF(A2,TODAY(),"ym")<=2),AND(DATEDIF(A2,TODAY(),"y")=0,DATEDIF(A2,TODAY(),"ym")=3,DATEDIF(A2,TODAY(),"md")=0)),"Tadpole", IF(OR(AND(DATEDIF(A2,TODAY(),"y")=0,DATEDIF(A2,TODAY(),"ym")<=5), AND(DATEDIF(A2,TODAY(),"y")=0,DATEDIF(A2,TODAY(),"ym")=6,DATEDIF(A2,TODAY(),"md")=0)),"Young Frog", IF(OR(DATEDIF(A2,TODAY(),"y")=0, AND(DATEDIF(A2,TODAY(),"y")=1, DATEDIF(A2,TODAY(),"ym")=0, DATEDIF(A2,TODAY(),"md")=0)), "Mature Frog", "Old Frog")))
Upvotes: 1