Age and DOB

mister_bluesman

New member
Local time
Today, 13:13
Joined
Jun 20, 2009
Messages
1
Hi everyone.

I've tried googling this but I dont seem find exactly what I need.

Basically I have a table with people's details, incuding their data of birth.

I have a form whereby I want to enter their age and filter all people who are at least that old in years. My issue is that I don't know how to go about converting their date of birth into an age and then placing that into a query that will look at their dates of birth. I guess I need to convert the age into some date and do some substraction...?

If anyone could give me some pointers that I would really appreciate it.

I hope I am making sense.

Thanks,
 
Hi -

This function will allow you return age in years based on specified date, or the current date (see the 3rd example). In your query try creating a calculated field, e.g.
CurrAge: fage2([DOB]) then, in the criteria cell >= 18, or whatever age you want to include.


Code:
Function fAge2(DOB As Date, Optional dteEnd As Variant) As Integer
're: http://www.access-programmers.co.uk/forums/showthread.php?t=116432
'coded by: raskew
'Inputs:  1) ? fAge2(#4/13/53#, #10/23/06#)
'         2) ? fAge2(#11/1/53#, #10/23/06#)
'         3) ? fage2(#4/13/53#)
'Outputs: 1) 53
'         2) 52
'         3) 56

   dteEnd = IIf(IsMissing(dteEnd), Date, dteEnd)
   fAge2 = DateDiff("yyyy", DOB, dteEnd) + (DateSerial(year(dteEnd), month(DOB), day(DOB)) > dteEnd)

End Function

HTH - Bob
 

Users who are viewing this thread

Back
Top Bottom