Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
DateDiff Incorrect Age
Tim Schmidt 
    
6 years ago
I am using the DateDiff() to calculate an age from the Birthdate on a table.  I am using this in a query and have the following
CURRAGE: DateDiff("yyyy",[BirDay],Now())
My issue is that it is not giving me a correct answer. The result will show say 39 when a person is still 38.   I have a birthday of 10/10/1981 and have a todays date of 10/20/2020, the age is
38, but I get a 39 in the query results
Richard Rost  @Reply  
          
6 years ago
This is because DateDiff only looks at the interval you specify. In this case, whole years. It doesn't take the months and days into consideration. So whether you enter:

DateDiff("yyyy",#10/10/1981#,#10/20/2020#)

or

DateDiff("yyyy",#10/30/1981#,#10/20/2020#)

you're going to get 39 because DateDiff is only calculating 2020-1981.

A better "simple" way to calculate age is like this:

Int((Date()-[DOB])/365.24)

So if you enter

Int((#10/20/2020#-#10/10/1981#)/365.24)

you get 39, but if you enter

Int((#10/1/2020#-#10/10/1981#)/365.24)

you get 38 because the person's birthday has not passed yet. This is a "good enough" example and it's correct 99% of the time, but it's not perfect. Leap years can throw it off. I cover a PERFECT way to calculate age in Access Expert 28.

BTW, in your example, the correct age SHOULD be 39. If someone's birthday is 10/10 and today is 10/20 then their birthday has passed, therefore 39 is the correct answer. But I understand your question.

This is an excellent question. Again, I do cover it in X28, but I'm going to add this to my TechHelp list for a future short video.
Richard Rost  @Reply  
          
6 years ago
New TechHelp: Calculate Age

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 2:31:02 PM. PLT: 0s