Re: Calculating age, given DOB & current date
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Sat, 18 Feb 2006 14:30:01 -0500
The usual formula is:
DateDiff("yyyy", [DOB], Date()) - _
IIf(Format(Date(), "mmdd") < Format([DOB], "mmdd"), 1, 0)
This is necessary because DateDiff is a little too literal in how it
calculates differences: to it, there's 1 year between 31 Dec, 2005 and 1
Jan, 2006. That's why you have to add the second part: to subtract one from
what DateDiff returns if the birthday hasn't happened yet this year.
Now, how were you planning on using this?
Hopefully, you know that you do not store Age in a table.
Your options are to create a query, and add the Age calculation as a
computed field in the query, or use it as the Control Source for a text box
on your form.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Paul Hyett" <pah@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:Gst$JGBUb29DFwdR@xxxxxxxxxxxxxxxxxxxxxxx
Hi, I'm a complete novice on Access, but with a lot of experience on
Excel.
How would I go about the above?
--
Paul 'Charts Fan' Hyett
.
- Follow-Ups:
- Re: Calculating age, given DOB & current date
- From: Paul Hyett
- Re: Calculating age, given DOB & current date
- References:
- Calculating age, given DOB & current date
- From: Paul Hyett
- Calculating age, given DOB & current date
- Prev by Date: Re: sorting controls ???
- Next by Date: Re: sorting controls ???
- Previous by thread: Calculating age, given DOB & current date
- Next by thread: Re: Calculating age, given DOB & current date
- Index(es):
Relevant Pages
|