Results 1 to 2 of 2

Thread: datediff

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    London
    Posts
    99

    Wink

    Want to find out somebody's age in years.

    CalculateAge = DateDiff("yyyy", dat, Now)

    The above almost works except that a new year is starting on 1st jan and not on their birthday.

    Any ideas?

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    this should give you a helping hand...

    example from my junk...

    Birthdate: February 06,1964
    Stored in mdb as 02061964



    Dim Bdate As String
    Dim Bage As Integer
    Dim Bdays As Long

    Bdate = "02061964"
    Bdate = Left$(Bdate, 2) + "/" + Mid$(Bdate, 3, 2) + "/" + Right$(Bdate, 4)
    Bage = DateDiff("yyyy", Bdate, Now)
    Bdate = DateAdd("yyyy", Bage, Bdate)
    Bdays = DateDiff("d", Now, Bdate)
    Select Case Bdays
    Case 0
    MsgBox "You are " + CStr(Bage) + "! Happy Birthday!"
    Case Is > 0
    MsgBox "Your birthday is in " + CStr(Bdays) + " days!"
    Case Is < 0
    MsgBox "Your birthday was " + CStr(Abs(Bdays)) + " days ago!"
    End Select

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width