Calculate an Age from Birth Date to current date

D

Doug

Hi,

First of all, almost everything else I've achieved to
date has been through reading this user group and finding
the answers from questions already asked and responded
to. You guys rock!!!

Second, I'm stumped by what I'm thinking should be a very
simple solution.

I'm trying to calculate a persons age from the date
of birth provided as at the current date and to populate
the result to the age field.

I would really appreciate some guidance, please.

Doug
 
D

Douglas J. Steele

DateDiff("yyyy", [DateOfBirth], Date()) - IIf(Format$(Date(), "mmdd") <
Format$([DateOfBirth], "mmdd"), 1, 0)

(note that that should be all on one line)

The DateDiff function is a little too literal: it's going to say there's a
year's difference between two dates if the years are a year apart, so that
it'll say DateDiff("yyyy", #12/31/2003#, #1/1/2004#) is 1 year. The second
part of the formula takes care of that: it subtracts one from the total if
they haven't had their birthday yet this year.
 

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