My Assistant
|
|
Feb 21 2003, 09:06 PM
Post
#1
|
|
|
UA Forum Administrator Posts: 38,131 From: Birmingham, Alabama USA |
This question comes up all the time so I thought I'd post the solution here in the FAQAs.
If you want to calculate the age in a query ... create a "Field Expression": Age: DateDiff("yyyy",[DOB],Date())+(Date()<DateSerial(Year(Date()),Month([DOB]),Day([DOB]))) If you want to calculate the age directly in the Control Source of a txtbox on a Form or Report ... use: = DateDiff("yyyy",[DOB],Date())+(Date()<DateSerial(Year(Date()),Month([DOB]),Day([DOB]))) "DOB" should be the name of the field that contains the "Date of Birth". You can find many "user defined" functions to calculate "age" ... but there is no need to create and use a user defined function as the expressions above will give you the correct result you want. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th June 2013 - 01:56 AM |