Brian Dunning's FileMaker Custom Functions

Age ( birthday ; today ; format )

This calculation determines a person's age based upon their birthday and a given date.

  Average rating: 4.0 (40 votes) Log in to vote

Kevin Kurpe   Kevin Kurpe
Grasp Learning
www.GraspLearning.com

Share on Facebook Share on Twitter

  Sample input:
Age (
GetAsDate ( "8/31/1948" ) ;
GetAsDate ( "1/19/2011" ) ; 4 )
  Sample output:
62 years
4 months
19 days

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

The function will calculate a persons age. The result of this function can be displayed in four different formats:

1: Years
2: Years and Days
3: Years, Months and Days.
4: Years ¶ Months ¶ Days



////////////////////////////////////////////////////
// CREDIT
////////////////////////////////////////////////////

// ORIGINALLY AUTHORED BY
// Chris Moyer
// Bob Bowers

// MODIFIED BY
// Geoff Wells, DataIsland Software LLC
// http://www.dataisland.com

// REWORKED BY
// Kevin Kurpe

 

Comments

chopper   chopper, east hampton
Aug 20, 2010
How is your function any different than this one

http://www.briandunning.com/cf/57

?
 
Kevin Kurpe   Kevin Kurpe, Saint Petersburg, FL
Aug 20, 2010
This is simply a reworking of that custom function. I added the contributions of Rob Wolf to fix an error with regard to the leap year.

I reorganized the custom function in order to make modifying the output easier.

Other than the fact that it's easier to read and manipulate, there is no difference.

Enjoy!
 
comment   comment, VR
Aug 22, 2010
This function returns incorrect results:

A person born on Jan 31, 1982 is 27 years old on Jan 31, 2009;
A year earlier, on Jan 31, 2008 the same person was 25 years old - TWO years younger.

Not to mention that on Mar 1, 2011 this person will be "29 years and 1 months, and -2 days" old.
 
Fritz Mills   Fritz Mills, Chicago, IL
Sep 1, 2010
When I copy and paste and attempt to save, it stops with an error. Also I don't understand the use of "<" and "≥" in the variable calculations, as they seem to be used on one side of an "=" calculation rather than in place of an "=" sign.
 
Gary Amstutz   Gary Amstutz, Sweetwater
Jan 2, 2011
DO NOT USE THIS FUNCTION! It is very error prone. If you look at the code, it ONLY looks at the two years (birth year and current year) to calculate the age, not accounting for which month of the year or day of the month the birthday is or the current date. So if the current day of the year is earlier than the day of the year of the birthdate, the age will be off by 1 year. It has other errors, too. Someone spent a lot of time formatting this, but didn't give the logic much thought. Don't use it.
 
Gary Amstutz   Gary Amstutz, Sweetwater
Jan 2, 2011
ADDITIONAL NOTE:

Use the one at
http://www.briandunning.com/cf/57

I just tried it, and it calculates the age correctly. This one doesn't!
 
Kevin Kurpe   Kevin Kurpe, Tampa, FL
Jan 19, 2011
I updated this custom function to address an error related to how I was calculating "leap years".

Thanks for the feedback Gary!
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.