Alpha Video Training
Results 1 to 7 of 7

Thread: Age Calculation

  1. #1
    Member
    Real Name
    Marios Karaiskakis
    Join Date
    Aug 2007
    Posts
    67

    Default Age Calculation

    I found a lot of information about how to calculate the age but none seems to be simple enough to use when calculating Age form the given date of birth.

    How to do this in a grid??

    Thank you for your time

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Age Calculation

    Are you able to create a calculated field/column in a grid?

    AGE( birthdate as D [, As_of_date as D ] )

    The As_of_date defaults to the current date so if you want the current age

    AGE( birthdate as D)


    Dt is a date field in the table represented.
    Last edited by Stan Mathews; 03-11-2011 at 06:34 PM.
    There can be only one.

  3. #3
    Member
    Real Name
    Marios Karaiskakis
    Join Date
    Aug 2007
    Posts
    67

    Default Re: Age Calculation

    Thank you Stan!!

    this looks nice! I will try it and let you know!

    Marios

  4. #4
    Member
    Real Name
    Marios Karaiskakis
    Join Date
    Aug 2007
    Posts
    67

    Default Re: Age Calculation

    It seems that this is not possible to my case because I am not using DBF table.
    I am using a SQL Table (MySQL on a cloud) and the option of inserting a calculated field or colum is not there (or I can't find it)!
    Is thre a way to make in the way you suggest it when using SQL Tables??

    Many Thanks again.

  5. #5
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Age Calculation

    With SQL tables I think you will have to define the age column in the SELECT statement. I'm certainly no expert at that. I do see that you can do this in the Enterprise Reporting section using the Expressions Tab.
    There can be only one.

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Age Calculation

    This works with the Northwind sample database.

    Code:
    SELECT EmployeeID, LastName, FirstName, BirthDate,  YearsBetweenDates(Birthdate,  Now() )  AS Age 
    FROM Employees
    There can be only one.

  7. #7
    "Certified" Alphaholic chadbrown's Avatar
    Real Name
    Chad Brown
    Join Date
    Aug 2007
    Location
    Aurora, Ontario, Canada
    Posts
    1,412

    Default Re: Age Calculation

    This works in Mysql

    Replace employees`.`birth_date` with your field

    Code:
    ((date_format(now(),'%Y') - date_format(`employees`.`birth_date`,'%Y')) - (date_format(now(),'00-%m-%d') < date_format(`employees`.`birth_date`,'00-%m-%d')))
    Chad Brown

Similar Threads

  1. Age Calculation
    By mgorom in forum Alpha Five Version 5
    Replies: 4
    Last Post: 10-01-2004, 07:01 AM
  2. Age Calculation Help
    By mgorom in forum Alpha Five Version 6
    Replies: 1
    Last Post: 09-30-2004, 02:57 PM
  3. Age Calculation
    By Paul Reese in forum Alpha Five Version 5
    Replies: 5
    Last Post: 01-30-2003, 10:46 AM
  4. Age Calculation
    By Brett Heintzman in forum Alpha Five Version 4
    Replies: 6
    Last Post: 01-27-2003, 05:57 PM
  5. Age Calculation
    By Debbie Bartlett in forum Alpha Five Version 4
    Replies: 2
    Last Post: 10-01-2002, 01:54 PM

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
  •