date functions

T

Turtle

Can anyone tell me how to get Access to calculate the age
of a person from their date of birth? Thanks in advance!
 
M

MUSIWA

-----Original Message-----
Can anyone tell me how to get Access to calculate the age
of a person from their date of birth? Thanks in advance!
.
You need to make a query using the DOB and the function
DATE() which gives you the current date. Then you do a
datedif(date(),DOB) What I did is to express the results
in days and then divide by 365 for the year and the rest
is a function of months. you can do it in hours if you
like and calculate days months and years. Also like at
the help for access on date functions for more syntax.
 
J

John Vinson

To calculate someone's age - create an expression in a
query using the following formula:

=DateDiff("y",[DateofBirth], Date()])/365

This will calculate the persons date of birth and the date
now (today) and give you their age. You will likely have
to format the field to be numeric.

This will be off a few days around the person's birthday, especially
for older folks - a year has 366 days in leap years, not 365.

A more reliable expression is:

=DateDiff("yyyy", [DateOfBirth], Date()) - IIF(Format([DateOfBirth],
"mmdd") > Format(Date(), "mmdd"), 1, 0)

This calculates the whole years, and then subtracts a year if the
person's birthday has not yet arrived.
 

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