age calculator that calulates age in days months yrs minutes seconds

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pratikm23
    New Member
    • Apr 2010
    • 9

    age calculator that calulates age in days months yrs minutes seconds

    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.
  • vb5prgrmr
    Recognized Expert Contributor
    • Oct 2009
    • 305

    #2
    Type in DateDiff and press F1.

    Comment

    • pratikm23
      New Member
      • Apr 2010
      • 9

      #3
      Originally posted by vb5prgrmr
      Type in DateDiff and press F1.
      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.

      Comment

      • vb5prgrmr
        Recognized Expert Contributor
        • Oct 2009
        • 305

        #4
        It is probably the way in which you are calculating the age... Lets see your code...



        Good Luck

        Comment

        • pratikm23
          New Member
          • Apr 2010
          • 9

          #5
          Originally posted by vb5prgrmr
          It is probably the way in which you are calculating the age... Lets see your code...



          Good Luck
          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

          Comment

          • vb5prgrmr
            Recognized Expert Contributor
            • Oct 2009
            • 305

            #6
            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

            Comment

            Working...