By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,251 Members | 2,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,251 IT Pros & Developers. It's quick & easy.

age calculator that calulates age in days months yrs minutes seconds

P: 9
I need to make an age calculator which inputs the date of birth from user and calulates age respectively. The age is shown in days,yrs,months, hours minutes and seconds.
Apr 9 '10 #1
Share this Question
Share on Google+
5 Replies


Expert 100+
P: 305
Type in DateDiff and press F1.
Apr 9 '10 #2

P: 9
@vb5prgrmr
I have tried this using datediff. but i am not getting a correct answer. The output in days is correct but the answer for no of months and years is +1 than the actual answer. Could u please help me fix this.
Apr 13 '10 #3

Expert 100+
P: 305
It is probably the way in which you are calculating the age... Lets see your code...



Good Luck
Apr 14 '10 #4

P: 9
@vb5prgrmr
This is the code from which i m getting the wrong output, plz help me correct this code:
Private Sub Command2_Click()
days = InputBox("enter DOB:")
z = Date
d = DateDiff("d", days, z)
e = DateDiff("m", days, z)
f = DateDiff("yyyy", days, z)
datetoday = Format("dd", Date)
monthtoday = Format("mm", Date)
yeartoday = Format("yyyy", Date)

MsgBox d & "days" & "," & e & "months" & "," & f & "years"
End Sub
Apr 14 '10 #5

Expert 100+
P: 305
Okay, you are going to have to test to see if the day month entered is greater than current day month or less than as it seems datediff is using simple math to calculate the difference...



Good Luck
Apr 14 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.