UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

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


UA Forum Administrator
Posts: 40,286
Joined: 8-February 00
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



Custom Search
RSSSearch   Top   Lo-Fi    29th August 2015 - 02:17 AM