Results 1 to 4 of 4
  1. #1
    muncher is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    2

    Age Calculation


    Is there a way to subtract a person's birthdate from a date (12/31/2014) so that it can yield an age for the person at that point in time (being the locked 2014 date)? I am thinking a calculated field in the customer table where their birthdate is stored.

  2. #2
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    http://www.techonthenet.com/access/f...e/datediff.php

    DateDiff ("yyyy", #15/10/1998#, #22/11/2003#)

    Result: 5

  3. #3
    muncher is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    2
    Thank you!

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Here is a function Age from a couple of years back that may be of use.

    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : Age
    ' Author    : Jack (from awf)
    ' Date      : 06-09-2012
    ' Purpose   : This routine determines the Age of a Person given their DOB.
    ' It accounts for the birthday this year (whether passed or not). A second parameter
    ' Specdate allows you to work from a different Date than today's date.
    'If SpecDate is missing, the routine defaults to today's date.
    '---------------------------------------------------------------------------------------
    ' Last Modified:
    '
    ' Inputs: N/A
    ' Dependency: N/A
    '--------------------------------------------------------------------------
    '
    Public Function Age(dteDOB As Date, Optional SpecDate As Variant) As Integer
        Dim dteBase As Date, intCurrent As Date, intEstAge As Integer
    10  On Error GoTo Age_Error
    
    20  If IsMissing(SpecDate) Then
    30      dteBase = Date
    40  Else
    50      dteBase = SpecDate
    60  End If
    70  intEstAge = DateDiff("yyyy", dteDOB, dteBase)
    80  intCurrent = DateSerial(Year(dteBase), Month(dteDOB), Day(dteDOB))
    90  Age = intEstAge + (dteBase < intCurrent)
    
    100 On Error GoTo 0
    110 Exit Function
    
    Age_Error:
    
    120 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Age of Module AWF_Related"
    End Function

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

Similar Threads

  1. BMI calculation
    By puush in forum Programming
    Replies: 9
    Last Post: 08-19-2014, 05:05 AM
  2. Calculation Field in table vs Query calculation
    By Leonidsg in forum Database Design
    Replies: 18
    Last Post: 02-28-2013, 09:38 PM
  3. Calculation
    By buienxg in forum Access
    Replies: 1
    Last Post: 11-16-2011, 07:20 AM
  4. Calculation
    By Maggie in forum General Chat
    Replies: 2
    Last Post: 10-16-2011, 12:49 PM
  5. Need help with calculation please
    By Gabriel984 in forum Forms
    Replies: 6
    Last Post: 09-09-2010, 12:06 PM

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