Results 1 to 5 of 5
  1. #1
    mrkaye is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Posts
    43

    Date Calculation


    I still need help, in my form I have a date of birth field, what I still need is a module that will give me how old a person is in years, months and days. all help welcome.
    TIA Marty

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    before we can get the answer, we must clairify this:
    if now is 11/10/2010, birthday is 5/11/2010, so the year is 0, month is 5, what is the day, 30 or 29?

  3. #3
    mrkaye is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Posts
    43

    does not work

    that does not work, I dont nknow why. I typed the field as you suggest, but aftert hitting the enter key, I get Expr1: [howold]=Format(Now()-[BirthDate],"yy-mm-dd")
    Than when I goto view it asked for Parameter value.

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I edit my post. something needs clarification.

  5. #5
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Following function returns the year,month and day,
    but may be inaccurate by one day. for example, today is 11/10/2010, if birthday is 10/11/2010, it return 0 - 0 - 29, however, it should be 30 days.

    Code:
    Function howOld(birthday As Date) As String
    'reutrn  yy-mm-dd
        Dim dd, mm, yy
     
        dd = Day(Now) - Day(birthday)
        mm = 0
        yy = 0
        If dd < 0 Then
            dd = dd + 30
            mm = -1
        End If
        mm = mm + Month(Now) - Month(birthday)
        If mm < 0 Then
            mm = mm + 12
            yy = -1
        End If
        yy = yy + Year(Now) - Year(birthday)
        howOld = yy & "-" & mm & "-" & dd
    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. date calculation then autofill?
    By nktrygg in forum Access
    Replies: 6
    Last Post: 01-19-2010, 11:04 AM
  2. Date Calculation ?
    By techexpressinc in forum Queries
    Replies: 2
    Last Post: 06-24-2009, 09:02 PM
  3. Date Calculation -- HELP!
    By klaauser in forum Forms
    Replies: 0
    Last Post: 12-22-2008, 02:14 PM
  4. Question about creating a date calculation tool
    By bazillion in forum Programming
    Replies: 0
    Last Post: 01-25-2008, 12:08 PM
  5. Date Calculation within same fields
    By mslieder in forum Queries
    Replies: 3
    Last Post: 01-26-2006, 10:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums