Results 1 to 2 of 2
  1. #1
    mommaof4kids is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Sep 2012
    Posts
    1

    Calculating age during a specific time frame

    Using Access 2003. I have an employee's DOB


    I need to know how old will the employee be during FY2012, FY2013, etc...

    I know the dates of my FY as follows:
    FY2012 10/01/2011 to 09/30/2012
    FY2013 10/01/2012 to 09/30/2013..etc..

    I don't really need to store the results, just be able to put into a report

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Here's a routine to calculate Age that accounts for their birthday having occurred yet or not. It also has a parameter whereby you can specify a Date different than today. If you omit the parameter, it defaults to today's date for calculating Age.
    I got this code from a forum but it seems to work well.
    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. Replies: 8
    Last Post: 08-24-2012, 01:54 AM
  2. Calculating Time
    By jlclark4 in forum Forms
    Replies: 0
    Last Post: 04-25-2011, 09:04 AM
  3. Replies: 0
    Last Post: 04-22-2011, 04:58 AM
  4. Replies: 12
    Last Post: 02-22-2011, 03:39 PM
  5. Need help with calculating Time total
    By Monoceros in forum Reports
    Replies: 1
    Last Post: 04-20-2009, 12:44 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