Formula for age

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

A formula I use to figure age as of 8/1/07 in Excel follows:

=DATEDIF(child's age,"8/1/2007","Y")

Can I use this formula in Access FORMS or REPORTS? If so, how?
 
I don't know why anything Micro$oft does surprises me anymore, but this did,
courtesy of DogPile!

"This function is available in all versions of Excel since version 5, but is
documented only in the help files for Excel 2000. It isn't documented in
either Excel 97 or Excel 2002. DATEDIF has, for whatever reason, been
treated as one of the drunk cousins of the Function Family. Excel knows he
lives a happy and useful existence, and will acknowledge his existence when
you ask, but will never mention him in "polite" conversation.

The syntax for DATEDIF is as follows:

=DATEDIF(Date1,Date2,Interval)"


I'm unaware of a built-in function DATEDIF in Excel, and Help in Excel 2003
turns up nothing. Even if it does exist in Excel, it doesn't exist in
Access.

See http://www.mvps.org/access/datetime/date0001.htm at "The Access Web" for
a discussion of various ways to calculate age.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
A formula I use to figure age as of 8/1/07 in Excel follows:

=DATEDIF(child's age,"8/1/2007","Y")

Can I use this formula in Access FORMS or REPORTS? If so, how?

By tweaking it a bit. DateDiff() in Access is different from the Excel
function. It doesn't really give the age - it gives the number of
year-boundaries between the date values, so DateDiff("yyyy", [DOB], Date())
will give an age of one year even if DOB is 12/31/2006 and today's date was
1/1/2007.

Try

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

Note that fieldnames should NOT contain apostrophes (or any other special
character, ideally) - they'll really mess up your queries and code!

John W. Vinson [MVP]
 

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

Back
Top