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

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
 
R

Rick B

=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.
 
G

Guest

Try this

IIf(DateDiff("m",StartDate,Date())<12,DateDiff("m",StartDate,Date()) & "
Months" , Int(DateDiff("m",StartDate,Date())/12) & " Years")
 
G

Guest

THAT WAS GREAT! IT WORKS! HOW ABOUT I ALSO SAY ANY CHILD UNDER 1 MONTH TELL
ME THE AGE BY WEEKS. CAN YOU HELP?
 
G

Guest

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")
 
G

Guest

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"))
 
G

Guest

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.
 

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

Top