Date of Birth

G

Guest

Hi,
I have a date of birth field in my database and want to know a formula to
use in a query for determine an individual's age.

Any help will be greatly appreciated.

KP
 
D

doodle

This was previously posted by dooug steele.

=IIf(DateSerial(2005, Month([Date of Birth]), Day([Date of Birth]) <
#10/01/2005#, 0, -1) + DateDiff("yyyy", [Date of Birth],
#10/01/2005#)


-doodle
 
F

fredg

Hi,
I have a date of birth field in my database and want to know a formula to
use in a query for determine an individual's age.

Any help will be greatly appreciated.

KP

In a query:
Age: DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") >
Format(Date(), "mmdd"), 1, 0)

Directly as the control source of an unbound control:
=DateDiff("yyyy",[DOB],Date())-IIf(Format([DOB],"mmdd")>Format(Date(),
"mmdd"),1,0)

You do know, I hope, that this Age computation should NOT be stored in
any table.
Just compute it and display it on a form or report, as needed.
 
J

John W. Vinson

I have a date of birth field in my database and want to know a formula to
use in a query for determine an individual's age.

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

John W. Vinson [MVP]
 
J

James A. Fortune

KenP said:
Hi,
I have a date of birth field in my database and want to know a formula to
use in a query for determine an individual's age.

Any help will be greatly appreciated.

KP

SELECT Int(Format(Date(), 'yyyy.mmdd') - Format([DOB], 'yyyy.mmdd')) AS
IndividualsAge FROM MyTable;

Better:

SELECT IIf([DOB] IS NULL, Null, Int(Format(Date(), 'yyyy.mmdd') -
Format([DOB], 'yyyy.mmdd'))) AS IndividualsAge FROM MyTable;

James A. Fortune
(e-mail address removed)
 

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