calcualting age issue

G

Guest

I have been on this site and have read and reread and tired all the queries I
have seen to calculate the age.....None are working and I just need some
help. I knwo this question has been asked and I am sorry I am replicating,
but someone please help me.

Trying to calculate the age from a DOB (ie 7/16/1978 = 27)

how simple I am sure this is and none of the FAQ queries worked....
I created a new filed called age, added the statement in the new field, and
nothing but 0 came up. the filed with the date of birth is "patient date of
birth"

I need help.....Probably mental, but...........
 
R

Rick B

The preferred formula for calculating age is...

DateDiff("yyyy",[Birthdate],Date())+(Format([Birthdate],"mmdd")>Format(Date(),"mmdd"))
 
D

Duane Hookom

The DateDiff() function by itself will not work. DateDiff() simply counts
the number of date interval "boundaries" that are crossed between two date
values. For instance
DateDiff("yyyy",#12/31/2005#, #1/1/2006#) = 1
DateDiff("yyyy",#1/1/2005#, #12/31/2006#) = 1

DateDiff("d",#12/31/2005#, #1/1/2006#) = 1
DateDiff("D",#1/1/2005#, #12/31/2006#) = 729

In the above examples, difference in days varies from 1 to 729 but the
difference in years is 1.

The code/expressions at www.mvps.org/access will always work if used
correctly.

--
Duane Hookom
MS Access MVP
--

Ofer said:
Did you try the DateDiff function?

DateDiff("yyyy",[Fieldname],Date())

And See thiis link:

http://www.mvps.org/access/datetime/date0001.htm
Date/Time: Calculate Age of a person

--
The next line is only relevant to Microsoft''s web-based interface users.
If I answered your question, please mark it as an answer. It''s useful to
know that my answer was helpful
HTH, good luck


BUCKPEACE said:
I have been on this site and have read and reread and tired all the
queries I
have seen to calculate the age.....None are working and I just need some
help. I knwo this question has been asked and I am sorry I am
replicating,
but someone please help me.

Trying to calculate the age from a DOB (ie 7/16/1978 = 27)

how simple I am sure this is and none of the FAQ queries worked....
I created a new filed called age, added the statement in the new field,
and
nothing but 0 came up. the filed with the date of birth is "patient
date of
birth"

I need help.....Probably mental, but...........
 
F

fredg

I have been on this site and have read and reread and tired all the queries I
have seen to calculate the age.....None are working and I just need some
help. I knwo this question has been asked and I am sorry I am replicating,
but someone please help me.

Trying to calculate the age from a DOB (ie 7/16/1978 = 27)

how simple I am sure this is and none of the FAQ queries worked....
I created a new filed called age, added the statement in the new field, and
nothing but 0 came up. the filed with the date of birth is "patient date of
birth"

I need help.....Probably mental, but...........

To accurately compute a persons age, use.....
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 (in a report or
on a form):
=DateDiff("yyyy",[DOB],Date())-IIf(Format([DOB],"mmdd")>Format(Date(),
"mmdd"),1,0)

Change [DOB] to whatever the actual name of the date of birth field
is.

This Age computation should NOT be stored in any table.
Just compute it and display it on a form or report, as needed.
 

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