+ Reply to Thread
Results 1 to 5 of 5

Calculate Age

  1. #1
    Forum Contributor
    Join Date
    10-04-2007
    Posts
    118

    Calculate Age

    I need to calculate the age of the student based on the [Date of Admission]

    I have two fields

    Field 1 [Date of Birth] - 11/10/1987
    Field 2 [Date of Admission] 09/09/2009

    I have CDate() both fields,

    How do I create a formula to calculate the student’s age?
    Last edited by akhlaq768; 07-17-2009 at 05:00 AM.

  2. #2
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Calculate Age

    Hi,

    Use the DateDiff Function

    DateDiff Function

    Returns a Variant (Long) specifying the number of time intervals between two specified dates.

    Syntax

    DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])

    The DateDiff function syntax has these named arguments:

    Part Description
    interval Required. String expression that is the interval of time you use to calculate the difference between date1 and date2.
    date1, date2 Required; Variant (Date). Two dates you want to use in the calculation.
    firstdayofweek Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed.
    firstweekofyear Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.

    Note ~ For date1 and date2, if the Calendar property setting is Gregorian, the supplied date must be Gregorian. If the calendar is Hijri, the supplied date must be Hijri.

    Example:

    AdmissionAge: DateDiff("yyyy",[Date of Birth],[Date of Admission])

    Cheers,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  3. #3
    Forum Contributor
    Join Date
    10-04-2007
    Posts
    118

    Re: Calculate Age

    i've tried what you suggested but having no luck
    Attached Files Attached Files

  4. #4
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Calculate Age

    Hi,

    Your table is storing the dates as "text", so you'll need to convert them to date format for the DATEDIFF function to work.

    Try this query:

    Please Login or Register  to view this content.
    Cheers,

  5. #5
    Registered User
    Join Date
    07-11-2009
    Location
    Essex, England
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Calculate Age

    Hi, Try this formula.

    (Date of admission minus dob)/365.25

    Dave.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1