Formula for age

T

tjsmags

A formula I use to figure age as of 8/1/07 in Excel follows:

=DATEDIF(child's age,"8/1/2007","Y")

Can I use this formula in Access FORMS or REPORTS? If so, how?
 
J

John W. Vinson

A formula I use to figure age as of 8/1/07 in Excel follows:

=DATEDIF(child's age,"8/1/2007","Y")

Can I use this formula in Access FORMS or REPORTS? If so, how?

By tweaking it a bit. DateDiff() in Access is different from the Excel
function. It doesn't really give the age - it gives the number of
year-boundaries between the date values, so DateDiff("yyyy", [DOB], Date())
will give an age of one year even if DOB is 12/31/2006 and today's date was
1/1/2007.

Try

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

Note that fieldnames should NOT contain apostrophes (or any other special
character, ideally) - they'll really mess up your queries and code!

John W. Vinson [MVP]
 
Top