429,251 Members | 2,727 Online
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
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