INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Microsoft: Access Other topics FAQ

Access Howto:

 How to calculate age (another method). by elizabeth faq181-85 Posted: 20 Jun 00 The following commonly-used function fails on a small percentage of dates; the specific failure dates depend on the birth date and current date.Function Age(Birthdate as Date) as Integer    Age = Datediff("d", Birthdate, Date) / 365.25End FunctionInstead try this:Function Age (Birthdate as Date) as Integer    Age = DateDiff("yyyy", Birthdate, Date) + _             (Date < DateSerial(Year(Date), Month(Birthdate), Day(Birthdate)))End FunctionThis takes advantage of the fact that True has a value of -1 and False has a value of 0... If this expression is True (the birthdate in the current year hasn't happened yet), you end up subtracting 1 day.If you want to enter your own end date instead of using today's date, here is the modification:Function Age(Birthdate As Date, Enddate as Date) As Integer    Age = DateDiff("yyyy", Birthdate, Enddate) +  _             (Enddate < DateSerial (Year(Enddate), Month(Birthdate), Day(Birthdate)))End Function- Mostly from an article by Ken Getz in MS Office & VB Developer Mag, p.64 Back to Microsoft: Access Other topics FAQ Index Back to Microsoft: Access Other topics Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!