Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare Dates for Age Result 3

Status
Not open for further replies.

awl

IS-IT--Management
Aug 2, 2001
136
US
Date Return Value

I’m using Access 97. I need to show the age of the individual. In a query I have the Date of Birth (DOB) and Current Date, in ddmmyy. I have shown the formula below(Age:). However, there seems to be one extra year that is added. Ei: DOB = 1/1/80; Current date = 10/18/01, shouldbe 35 years of age. In my original formula I did not divide by 365 which the resulted was 13074. I then changed my formula to divide by 365. The results come to 36, standard number format. Can someone provide a better formula? Thank you.

DOB
Current Date: Date()

Age: Sum([Current Date]-[DOB])/365
 
LOL, actually someone born on 1/1/1980 should be 21, not 35.

I use Int((Date()- [birthdate])/365.25) to calculate age. Maq B-)
<insert witty signature here>
 
try reversing your division sign and see if that helps. instead of a forward slash to divide use a backslask like:


Age: Sum([Current Date]-[DOB])\365


that will truncate the remainder from your calculation and then the number format will not automatically round it up.

Hope this helps....
 
Thank you both Macquis and jitter. I tried both ideas and the results is what I was looking for. Of the two: I decided to use Macquis's formula, since I did not have to have an extra calculated field in the query which was the Current Date. Macquis: the sample I gave you was incorrect; though I had many records, I provided the wrong birthyear. Thank you both for responding. Curtis....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top