G
Guest
i need help to calculate age by using dob.what kind of field do i need for
the dob and what kind of format?
thanks irit
the dob and what kind of format?
thanks irit
Douglas J. Steele said:DOB should be a date field.
Age (in years) is calculated as
DateDiff("yyyy", [DOB], Date) - _
IIf(Format([DOB], "mmdd") < Format(Date, "mmdd"), 1, 0)
DateDiff calculates how many "year crossings" occur between the two dates:
it'll say that there's 1 year between 31 Dec of one year and 1 Jan of the
next year, despite the fact that it's really only 1 day. That's why you
subtract 1 from the calculation if the birthday hasn't taken place yet this
year.
If you want finer granularity than years, (say 28 year, 7 months and 2
days), see http://www.accessmvp.com/DJSteele/Diff2Dates.html
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Imarko said:i need help to calculate age by using dob.what kind of field do i need for
the dob and what kind of format?
thanks irit
Daniel said:
Imarko said:I used itlike this but it is not working,I change the format in the
ageyearly
to a date formal(mm/dd/yyyy)
AgeYearly = DateDiff("yyyy", [DOB], Date) - _
IIf(Format([DOB], "mmdd") < Format(Date, "mmdd"), 1, 0)
still it is not working
thanks Irit
Douglas J. Steele said:DOB should be a date field.
Age (in years) is calculated as
DateDiff("yyyy", [DOB], Date) - _
IIf(Format([DOB], "mmdd") < Format(Date, "mmdd"), 1, 0)
DateDiff calculates how many "year crossings" occur between the two
dates:
it'll say that there's 1 year between 31 Dec of one year and 1 Jan of the
next year, despite the fact that it's really only 1 day. That's why you
subtract 1 from the calculation if the birthday hasn't taken place yet
this
year.
If you want finer granularity than years, (say 28 year, 7 months and 2
days), see http://www.accessmvp.com/DJSteele/Diff2Dates.html
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Imarko said:i need help to calculate age by using dob.what kind of field do i need
for
the dob and what kind of format?
thanks irit
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.