Date of Birth as Years age

G

Guest

I want to calculate age in years and am using the following formula

=DatePart("yyyy",Date())-DatePart("yyyy",[Date of Birth])

The answer i am getting is, I assume, being rounded up to the next whole
number as it usually give me 1 too many years.

What should I do?
 
G

Guest

Use this then format the answer using the <format ()> function to accuracy
you want.

=Now() - [Date of Birth] - 1
 
F

fredg

I want to calculate age in years and am using the following formula

=DatePart("yyyy",Date())-DatePart("yyyy",[Date of Birth])

The answer i am getting is, I assume, being rounded up to the next whole
number as it usually give me 1 too many years.

What should I do?



Using the Access DateDiff function, someone born 12/31/2004 is
considered 1 year old on 1/1/2005, which I think is not correct.

To compute the correct age in years, you must take into account
whether or not the person's birth month and day has yet occurred in
the current year.

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.
 
G

Guest

You right, thank you.
Mybe that would be better then
=int(datediff("m",#12/31/2004#,#1/1/2005#)/12)

fredg said:
I want to calculate age in years and am using the following formula

=DatePart("yyyy",Date())-DatePart("yyyy",[Date of Birth])

The answer i am getting is, I assume, being rounded up to the next whole
number as it usually give me 1 too many years.

What should I do?



Using the Access DateDiff function, someone born 12/31/2004 is
considered 1 year old on 1/1/2005, which I think is not correct.

To compute the correct age in years, you must take into account
whether or not the person's birth month and day has yet occurred in
the current year.

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.
 
G

Guest

Many thanks Fred, that certainly does the trick.

I did not realise I couldn't keep ages on a data base, but I am not doing. I
keep the date of birth and calculate the age for a printed form. Also my data
base relates to dogs not people.
Again thanks for the info.



fredg said:
I want to calculate age in years and am using the following formula

=DatePart("yyyy",Date())-DatePart("yyyy",[Date of Birth])

The answer i am getting is, I assume, being rounded up to the next whole
number as it usually give me 1 too many years.

What should I do?



Using the Access DateDiff function, someone born 12/31/2004 is
considered 1 year old on 1/1/2005, which I think is not correct.

To compute the correct age in years, you must take into account
whether or not the person's birth month and day has yet occurred in
the current year.

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.
 
F

fredg

Many thanks Fred, that certainly does the trick.

I did not realise I couldn't keep ages on a data base, but I am not doing. I
keep the date of birth and calculate the age for a printed form. Also my data
base relates to dogs not people.
Again thanks for the info.

fredg said:
I want to calculate age in years and am using the following formula

=DatePart("yyyy",Date())-DatePart("yyyy",[Date of Birth])

The answer i am getting is, I assume, being rounded up to the next whole
number as it usually give me 1 too many years.

What should I do?

Using the Access DateDiff function, someone born 12/31/2004 is
considered 1 year old on 1/1/2005, which I think is not correct.

To compute the correct age in years, you must take into account
whether or not the person's birth month and day has yet occurred in
the current year.

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.

Ah! But then some people are dogs! :-(
 

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