UtterAccess.com
We have detected that you are using an unsupported web browser. We recommend you to upgrade your web browser to get the most from UtterAccess forums.
Why should and how can I upgrade?
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

> How to Calculate Age .....    
 
   
R. Hicks
post Feb 21 2003, 09:06 PM
Post #1

UA Forum Administrator
Posts: 40,051
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 the top of the page
 
+

Posts in this topic
- R. Hicks   How to Calculate Age .....   Feb 21 2003, 09:06 PM


Thank you for your support! Closed TopicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 31st October 2014 - 01:11 AM