AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Richard Rost
Expertise
I am happy to answer any kinds of questions about Microsoft Access - from basic table design to advanced VBA programming. Also, please feel free to check the Access Tips & Tricks section of my web site.

Experience
I am the president of AccessLearningZone.com and 599CD.com. I specialize in Microsoft Access Tutorials. I have been teaching Access in the classroom since 1994, and online since 2002.

Education/Credentials
I am a self-taught Access expert. I have been building databases for clients since the early 90s. You can see a sample of my Access Tutorials on my web site at 599CD.com

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > Calculating Age in Access 2007

Using MS Access - Calculating Age in Access 2007


Expert: Richard Rost - 7/9/2009

Question
Hi,

I am trying to calculate age in Access 2007. I need the exact age, not just the datediff age. I have seen several places where they offer code but for some reason the code examples do not work for me. Is there a difference in the code between Access 2003 and 2007? I am trying to calculate the age from my BirthDate field.

I have intermediate Access experience.

Answer
How exact? To the day? DateDiff is pretty exacting, but you could also just use regular old date subtraction:

=Now()-DOB

That will result in the number of days the person has been alive. You can divide out to get years.

See:

There are many different things you can do with dates and times in Access.

You can use the DateAdd function to add or subtract date values. Want to add 6 months to a date but aren't sure which months between have 28 or 31 days? DateAdd takes care of that. It's also good for time values.

Please see the following FREE video tutorial on my web site for step-by-step instructions on how to use the DateAdd function:

http://599cd.com/tips/access/number-of-months-alive/?key=AllExperts


You can also use the DateDiff function to calculate the difference between two dates or times. This is useful for calculating the number of hours worked, someone's age, or even the number of school days in a year.

Here's a FREE video tutorial that discusses how to do some of that:

http://599cd.com/tips/access/dates-datediff-dateadd/?key=AllExperts


Now, one thing I get asked about ALL the time is how to figure out the number of days someone has to work, but EXCLUDE holidays like Christmas or Thanksgiving. Well, this is not so easy because some holidays (like Thanksgiving) fall on different calendar dates from year to year. In order to do this, you need to create a lookup table for your holidays, and use some advanced programming.

Unfortunately, I don't have a free tutorial that explains this in detail, but I do cover it in my Access 325 course, in lesson 4. We build a table to track student attendence, and we use a Holiday Table to know which days the students don't have to be in class. Here's the link:

http://599cd.com/site/courselist/access/access325/?key=AllExperts


I hope this helps.

Let me know if you have any other questions or comments.

Also, be sure to visit my web site and watch my FREE 90-minute MICROSOFT ACCESS VIDEO TUTORIAL. Go to http://www.599cd.com/Access/AllExperts


Cordially,

Richard Rost
599CD Computer Training
http://www.599cd.com

P.S. Also, don't forget to visit my FREE Microsoft Access Tips & Tricks Page at http://www.599cd.com/Tips/AllExperts

P.P.S. I volunteer my time at AllExperts to help people, and I get a LOT of questions, so I can't take an hour to answer each question. If you need more DETAILED HELP, come to my TechHelp web site at http://www.599cd.com/TechHelp/AllExperts and I'll take as much time as you need to answer your question.

http://www.599cd.com/Microsoft_Access_Tutorial?key=AllExperts

Out of work? Know someone who is? Get a FREE copy of my Computer Job Skills CD at http://www.599cd.com/JobSkills?key=AllExperts

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.