X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Closed TopicStart new topic
> How to Calculate Age .....    
R. Hicks
post Feb 21 2003, 09:06 PM

UA Forum Administrator
Posts: 40,505
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

Custom Search

RSSSearch   Top   Lo-Fi    25th August 2019 - 09:39 PM