AboutRichard 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.
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
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:
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:
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:
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.