Age Calculation

K

KantFigureItOut

Hello All,
I am needing help. I am wanting to enter a Date of Birth and know what age a
person is on a certain date, let's say August 1st of the current year. Does
anyone out there know how to do this. The expression I am currently using is
something like this:

Expr4: DateDiff("yyyy", BirthDate ,(08/01/2005)) + CInt(Format(BirthDate,
"MMDD") > FORMAT((08/01/2005),"MMDD"))

BirthDate is the Field Name used in my table for their Date of Birth
The (08/01/2005) is me not knowing what I am doing. Any help out there would
be greatly appreciated.

Thanks Everyone, Jeff
 
M

Michel Walsh

Hi,


08/01/2005 is two divisions.


DateDiff("yyyy", BirthDate ,(#08/01/2005#)) + CInt(Format(BirthDate,
"MMDD") > FORMAT((#08/01/2005#),"MMDD"))



should work, the # delimiter signals to not "divide" but to consider the
data as a date, a US date if possible.


Hoping it may help,
Vanderghast, Access MVP
 
F

fredg

Hello All,
I am needing help. I am wanting to enter a Date of Birth and know what age a
person is on a certain date, let's say August 1st of the current year. Does
anyone out there know how to do this. The expression I am currently using is
something like this:

Expr4: DateDiff("yyyy", BirthDate ,(08/01/2005)) + CInt(Format(BirthDate,
"MMDD") > FORMAT((08/01/2005),"MMDD"))

BirthDate is the Field Name used in my table for their Date of Birth
The (08/01/2005) is me not knowing what I am doing. Any help out there would
be greatly appreciated.

Thanks Everyone, Jeff

Dates must be surrounded by the date delimiter #, otherwise Access
does not recognize it as a data value.

This is the expression I would use:

Age: DateDiff("yyyy", [BirthDate], #8/1/2005#) - IIF(Format(
[BirthDate], "mmdd") > Format(#8/1/2005#, "mmdd"), 1, 0)
 
K

KantFigureItOut via AccessMonster.com

Thanks everyone for the help I believe this is going to work. Now I just have
to test it out with a few different dates to see if that is what I need it to
do.
 

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