looking for age formula, but if under 1 yr than give months

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know the formula to get the age, but I can't figure out the formula if a
child is less than one year old than give age by the month otherwise give age
by year. I am using an unbound textbox in a form in ACCESS
 
=IIf(Year()-[Birthdate]<365,(DateDiff("m",[birthdate],Date()) Mod 12 & "
mts."),(DateDiff("yyyy",[Birthdate],Date())+(Format([Birthdate],"mmdd")>Format(Date(),"mmdd")))

I might have the syntax off a bit (check the opening and closing
parenthesis, but the idea should be correct.
 
Try this

IIf(DateDiff("m",StartDate,Date())<12,DateDiff("m",StartDate,Date()) & "
Months" , Int(DateDiff("m",StartDate,Date())/12) & " Years")
 
THAT WAS GREAT! IT WORKS! HOW ABOUT I ALSO SAY ANY CHILD UNDER 1 MONTH TELL
ME THE AGE BY WEEKS. CAN YOU HELP?
 
Not sure if it is the best way and how accurate it will be, but you can try
this

IIf(DateDiff("d",StartDate,Date())<30,DateDiff("ww",StartDate,Date()),IIf(DateDiff("m",StartDate,Date())<12,DateDiff("m",StartDate,Date()) & "
Months" , Int(DateDiff("m",StartDate,Date())/12) & " Years")
 
I missed a closing brackets

IIf(DateDiff("d",StartDate,Date())<30,DateDiff("ww",StartDate,Date()),IIf(DateDiff("m",StartDate,Date())<12,DateDiff("m",StartDate,Date()) & "
Months" , Int(DateDiff("m",StartDate,Date())/12) & " Years"))
 
Thank you again, after tweeking just a little bit It WORKS! Thank you, Thank
you! You have saved me much of a headache. I have been playing with this
for days. I finally decided to ask for help. I really do appreciate this.
 
Back
Top