Help with if statement

C

ck

I have used the following statement, but it is returning an incorrect result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203>="0years,0months",E203<="0years,3months"),"0-3",IF(AND(E203>"0years,3months",E203<="0years,6months"),"3-6",IF(AND(E203>"0years,6months",E203<="2years,0months"),"6m
- 2y",IF(AND(E203>"2years,0months",E203<="99years,0months"),"Older than
2",""))))
 
G

Glenn

ck said:
I have used the following statement, but it is returning an incorrect result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203>="0years,0months",E203<="0years,3months"),"0-3",IF(AND(E203>"0years,3months",E203<="0years,6months"),"3-6",IF(AND(E203>"0years,6months",E203<="2years,0months"),"6m
- 2y",IF(AND(E203>"2years,0months",E203<="99years,0months"),"Older than
2",""))))

What is in E203?
 
N

nita

ck, I played with your formula and found that if you use 00years,00months --
create the accepability of a double digit number -- which you will have since
the months in a year may be a single or a double digit number (0, 1, 2, . . .
9, 10, 11). Just change the formula to read:
 
C

ck

e203 contains the age calculated in years and months by using the following
formula: =DATEDIF(D203,B203,"y")&"years,"&DATEDIF(D203,B203,"ym")&"months"
 
C

ck

I changed the formula and I am still getting errors...Do I need to change
anything to create the acceptability of a double digit number?
 
G

Glenn

OK, so E203 contains TEXT. Try this instead:

=IF(DATEDIF(D203,B203,"M")<3,"0-3",IF(DATEDIF(D203,B203,"M")<6,"3-6",
IF(DATEDIF(D203,B203,"M")<24,"6m - 2Y","Older than 2")))
 
D

David Biddulph

Did you remember to change your E203 formula to give 2 digits for years and
months? Does your formula look like:
=TEXT(DATEDIF(D203,B203,"y"),"00")&"years,"&TEXT(DATEDIF(D203,B203,"ym"),"00")&"months"
?
 
C

ck

You are a genious! Thank you! Thank you!

Glenn said:
OK, so E203 contains TEXT. Try this instead:

=IF(DATEDIF(D203,B203,"M")<3,"0-3",IF(DATEDIF(D203,B203,"M")<6,"3-6",
IF(DATEDIF(D203,B203,"M")<24,"6m - 2Y","Older than 2")))



.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

age 3
If Function 1
Multiple IF Statement in Word 5
IIF condition 3
Custom Sort 1
Page numbering with Merged Document and IF statements 1
Nested If Statement help 1
IF Statement with AND Statement 4

Top