Format of formula result for calculated age

V

--Viewpoint

I was able to successfully calculate ages with the formula provided by
responders on this site (=DateDiff formula). Thanks you.

Now, to take it one step further, is it possible for the result of the
calculated formula to print age
as: 10 year 2 months?
 
6

'69 Camaro

Hi.
Now, to take it one step further, is it possible for the result of the
calculated formula to print age
as: 10 year 2 months?

Yes. Since you are doing this in a report, the calculations should be set
up in the query. An example of a query calculating a person's age in years
and months on July 1, 2004 would be:

SELECT PersID, DOB,
(DateDiff("yyyy", DOB, #07/01/2004#) + Int("0701" < Format(DOB, "mmdd")))
AS Age,
(DateDiff("m", DOB, #07/01/2004#) - (Age * 12) + Int("01" < Format(DOB,
"dd"))) AS Mos,
Age & " years " & Mos & " months" AS YrsAndMos
FROM tblPersons;

.... where PersID is the primary key of the tblPersons table, indicating the
record of the person. DOB is the person's date of birth.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. (Only "Answers" have green
check-marks.) Remember that the best answers are often given to those who
have a history of rewarding the contributors who have taken the time to
answer questions correctly.
 
Top