Help with DOB formula.

D

Debbie

I notice that if a child is born on 2/27/07, for exampe, this formula
states that he is only 6 months on 10/1/07. What is wrong with my
formula. The child turned 7 months on Sept 27th.

AgeYear: Int((Date()-[DOB])/365)

Thank you in advance!
 
F

fredg

I notice that if a child is born on 2/27/07, for exampe, this formula
states that he is only 6 months on 10/1/07. What is wrong with my
formula. The child turned 7 months on Sept 27th.

AgeYear: Int((Date()-[DOB])/365)

Thank you in advance!

What do you want it to say?
7 Months or 0 Years.

The usual usage of Age is to compute by years.

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.

If you are looking for something like 0 Years and 7 Months and 5 days,
then see
"A More Complete DateDiff Function" at
http://www.accessmvp.com/djsteele/Diff2Dates.html
 
D

Debbie

Debbie said:
I notice that if a child is born on 2/27/07, for exampe, this formula
states that he is only 6 months on 10/1/07. What is wrong with my
formula. The child turned 7 months on Sept 27th.
AgeYear: Int((Date()-[DOB])/365)

This should help:http://www.mvps.org/access/datetime/date0001.htm

I had it so that if the child was under a 2 years it would give me
months and years over a 2 year, but I noticed that it did not
calculate if the child was 7 months on 9/27 it still said child was 6
months. Child was born 2/27.
No I do not put it in table. I use it for our Age report. We are a non-
profit organization and we have a daycare, and many cases I need to
know how old the child for transferring from one class to another or
for rates, or for whatever other reasons come about.
 
J

John W. Vinson

I notice that if a child is born on 2/27/07, for exampe, this formula
states that he is only 6 months on 10/1/07. What is wrong with my
formula. The child turned 7 months on Sept 27th.

AgeYear: Int((Date()-[DOB])/365)

Thank you in advance!

This expression will give you an integer number of years - and will NOT give
you any ages in months. For the example you provide it will return 0. Either
you're using a different formula, or you're misinterpreting the results!

What is the *actual* expression you're using? Doublecheck your query!

John W. Vinson [MVP]
 
J

John Spencer

Your formula calculates fractions of a YEAR. If you want months then you
need to multiply the result by 12 to get an approximation based on a month
being 30.42 days.

Int(Date()-#2/27/07#)/365 = 0.597260273972603 (Years)
0.597260273972603 * 12 = 7.16712328767124 (Months)

Or all in one and stripping off the fractional part of the month
Int(((Date()-#2/27/07#)/365) * 12) = 7

That said, you might want to look into the other responses to get a better
solution.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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