Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

Age ( Birth; theDate; Format )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 3.9  (36 votes)
  Discuss this Custom Function

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

Calculates Age in three formats

Sample Input:
Age ( 5/14/1946; 5/11/2004; 3 )
Sample Output:
57 years and 11 months, and 27 days


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

The Age function will calculate a persons age, on any date, in three different formats -

1 / Years
2 / Years and Days
3 / Years, Months and Days.

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

This is my Custom Function and I want to edit it

Discuss:

5 most recent comments | Show all 7 comments

Sorry, Alexis, but check your calendar again. 2000 WAS a leap year, because it's divisible by 400. The 'century' years are normally not leap years (1800, 1900), except when divisible by 400. So the calc for leapFactor should really be:

leapFactor = Case ( Mod ( Year ( theDate ) ; 400 ) = 0 ; 1 ;
// 'century' years divisible by 400 are leap years
Mod ( Year ( theDate ) ; 100 ) = 0 ; 0 ;
// 'century' years not divisible by 400 are not leap years
Mod ( Year ( theDate ) ; 4 ) = 0 ; 1 ;
// years divisible by 4 are leap years
0 )

Rob Woof, Sydney/Australia
August 08, 2010 7:13pm

There's another way that bypasses the Case statement.

leapFactor = If ( Mod ( Year ( theDate ) ; 400 ) = 0 ; 1 ; 0 ) // 'century' years divisible by 400 are leap years
- If ( Mod ( Year ( theDate ) ; 100 ) = 0 ; 1 ; 0 ) // 'century' years not divisible by 400 are not leap years
+ If ( Mod ( Year ( theDate ) ; 4 ) = 0 ; 1 ; 0 ) // years divisible by 4 are leap years

A year that is divisible by 400 (e.g. 1600, 2000) will evaluate to 1 - 1 + 1 = 1.
A year that is divisible by 100 but not by 400 (e.g. 1300, 1900) will evaluate to 1 - 1 + 0 = 0.
A year that is divisible by 4 but not by 100 (e.g. 1972, 1988) will evaluate to 1 - 0 + 0 = 1.
Any other year (i.e. not a leap year) will evaluate to 0 - 0 + 0 = 0.

Just another way to skin this particular cat.

Rob Woof, Sydney/Australia
August 11, 2010 8:48pm

No need to do this at all: FileMaker will handle leap years itself if you use it's own date comparisons.
Go look at http://www.briandunning.com/cf/518

That one lets you pick a comparison date (just use Get( CurrentDate ) for the second parameter if you want current age), handles negative age comparisons, and returns multiple formats.

Also, it has the decided advantage of actually returning correct values, even when dealing with leap years and on the actual birthday anniversary because it uses FileMaker's own date comparisons to get it right.

Daniel A. Shockley, New York, NY
May 04, 2011 11:16am

Doesn't seem to work for Leap Years. Try 2008 and Feb28th then Feb29th then Mar1. It skips a date.

David, Sacramento
December 10, 2013 8:51pm

To be perfect, we also need to take in account the "combination" of the 4, 100 and 400.

Let (

leapFactor =

Case (

// Divisible by 4
// not by 100 and 400, such as 2012, 2016
Mod ( Year ( theDate ) ; 4 ) = 0 and
Mod ( Year ( theDate ) ; 100 ) ≠ 0 and
Mod ( Year ( theDate ) ; 400 ) ≠ 0 ;
1 ; // Leap Year

// Divisible by 4 and 100
// not by 400, such as 2200, 2300, 2500, 2600 are common years
Mod ( Year ( theDate ) ; 4 ) = 0 and
Mod ( Year ( theDate ) ; 100 ) = 0 and
Mod ( Year ( theDate ) ; 400 ) ≠ 0 ;
0 ; // Common Year

// Divisible by 4 and 100 and 400
// such as 1600, 2000, 2400 are leap years
Mod ( Year ( theDate ) ; 4 ) = 0 and
Mod ( Year ( theDate ) ; 100 ) = 0 and
Mod ( Year ( theDate ) ; 400 ) = 0 ;
1 ; // Leap Year

0 // else are Common Years

)
) ;

Ukyo Matsushita, Tokyo/Japan
September 15, 2016 1:53am

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 2 + 5 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)
2. MonthYearList ( startmonth ; startyear ; numbermonth ; short )
  (Mon, Oct 16, 3:38am)
3. ErrorDescription ( errorNumber )
  (Wed, Sep 27, 2:51am)
4. decodeEntities (text)
  (Wed, Sep 27, 1:22am)
5. HexidecimalToNumber ( HexidecimalValue ; counter )
  (Mon, Sep 25, 12:39pm)
6. FixedFieldConverter ( Fieldname ; f1 ; f2 ; f3 ; f4 ; f5 ; f6 ; f7 ; f8 ; f9 ; f10 ; f11 ; f12 ; f13 ; f14 ; f15 ; f16 ; f17 ; f18 ; f1
  (Fri, Sep 15, 12:34pm)
7. ShannonEntropy ( text )
  (Thu, Sep 07, 5:59am)
8. LetterCount ( text ; summary )
  (Thu, Sep 07, 5:53am)

RSS Feed of Custom Functions