How can I display age in short?

G

Guest

After entering into the control source for age the following,
=DiffDates("ym",[BIRTHDATE],Now()) my report shows age in Years and months
i.e. 4 years 25 months. I would like display the age in short form like 4Y
25 M. How do I go about this? Kindly help.
 
J

John W. Vinson

After entering into the control source for age the following,
=DiffDates("ym",[BIRTHDATE],Now()) my report shows age in Years and months
i.e. 4 years 25 months. I would like display the age in short form like 4Y
25 M. How do I go about this? Kindly help.

You'll probably need to edit the (non-Access, third party) DiffDates function.
At some point it constructs a string incorporating the literal string
" years " - you'' want to edit it to "Y".

Surely your example isn't right? There are only 12 months in a year; 4Y25M
doesn't seem to make sense!

John W. Vinson [MVP]
 
G

Guest

This is the formula for calculating age from a DOB
=DateDiff("yyyy",[BIRTHDATE],Now())+Int(Format(Now(),"mmdd")<Format([BIRTHDATE],"mmdd"))

You can fiddle around with the Format() specifiers to get the output you want.

Steve
 
D

Douglas J. Steele

Except that doesn't give years and months, which appears to be what's
desired.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


SteveM said:
This is the formula for calculating age from a DOB:
=DateDiff("yyyy",[BIRTHDATE],Now())+Int(Format(Now(),"mmdd")<Format([BIRTHDATE],"mmdd"))

You can fiddle around with the Format() specifiers to get the output you
want.

Steve

njogus said:
After entering into the control source for age the following,
=DiffDates("ym",[BIRTHDATE],Now()) my report shows age in Years and
months
i.e. 4 years 25 months. I would like display the age in short form like
4Y
25 M. How do I go about this? Kindly help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top