Age Difference Date/Time Field

F

Fred

First time doing this so if this is a ridiculous question my apologies.
Is it possible to fill the field Age field automatically and/or on Merge to
a Word document using a macro?

Table: Contacts

Birthday Date/Time
Age DateTime update each year on output according to Macro?

Where does one put the code for Age field to generate the current Age field
automatically if one can based on the date in Birthday field.

If I merge AGE I expect it to put 32 if person's BIRTHDAY field was 32 years
ago? Can I put a macro in the field?

Age:
DateDiff("yyyy",[Birthday],Now())+Int(Format(Now(),"mmdd")<Format([Birthday],"mmdd"))

I want the field to calculate age. I can achieve it in a report but can I
apply it to a field?

Many thanks.
 
G

Guest

If you have the date of birth, you don't need to store the age. Anywhere you
need to display or use the age can be done with a calculation.
 
J

John Vinson

Age:
DateDiff("yyyy",[Birthday],Now())+Int(Format(Now(),"mmdd")<Format([Birthday],"mmdd"))

I want the field to calculate age. I can achieve it in a report but can I
apply it to a field?

Certainly. If you copy the expression on the line above into a vacant
Field cell in a Query, it will calculate the age based on the
birthday. I'd suggest changing Now() to Date() however, since Now()
unnecessarily includes the current time to the second.

The Query can be used as the basis for a mail merge to Word. You don't
need to use a Table for that purpose, in fact a query would be much
more common!

John W. Vinson[MVP]
 

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