On Wed, 5 Dec 2007 10:19:01 -0800, karen k-12 <karen
I have a table containing student birthdates (yyyymmdd).
What's the datatype of this field? Number? Text? Maybe even a Date/Time field
(which is what you want)?
This information
was collected Spring 2007. I need to calculate the age of the student at
that time. Could you please help me create a calculated field for this table
that displays the age. Thanks.
You cannot and should not store calculated fields in a Table.
If you have the birthdate in a Date/Time field, you can use a Query, or the
control source of a textbox in a Form or Report, to dynamically calculate the
age:
Age: DateDiff("yyyy", [Birthdate], Date()) - IIF(Format([Birthdate], "mmdd") >
Format(Date(), "mmdd"), 1, 0)
If your field is a text field, you can use
CDate(Format([textbirthdate], "@@@@-@@-@@"))
in place of [birthdate] in the age expression - but you'ld do better to create
a date/time field and use an update query with the same CDate expression to
populate it.
John W. Vinson [MVP]