# Thread: age calculations (access xp)

1. ## age calculations (access xp)

Hi, I know this has been posted but since I can't search I'll have to ask again. I need to find out how old students were at the time they took a test. I have this
Expr1: INT((12/15/2002-[Students]![Birthdate])/365.25) in a calculated field in my query but end up with a negative number with two decimal places. How do I need to change this? Thanks, Tammy

By the way, I really miss being able to search this forum. Any news on when that will function again?

2. ## Re: age calculations (access xp)

You must enclose a date in # symbols: #12/15/2002#, otherwise it will be interpreted as a calculation "12 divided by 15 divided by 2002".

Another way is to use a function:

Function Age(BirthDate, LaterDate) As Integer
' Returns the Age in years between 2 dates
' LaterDate must be after BirthDate
Age = Year(LaterDate) - Year(BirthDate)
If Month(LaterDate) < Month(BirthDate) Or (Month(LaterDate) = Month(BirthDate) And _
Day(LaterDate) < Day(BirthDate)) Then
Age = Age - 1
End If
End Function

Use this in the form

StudentAge: Age([Students]![BirthDate],#12/15/2002#)

P.S. I'm very sorry, but I have no idea when the search function will be back. When there are new developments, they will be announced in the Newsflash.

3. ## Re: age calculations (access xp)

Thanks Hans. Sometimes you miss the simplest things!!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•