AgeCalculation ( )

Function stats

Average user rating
FileMaker 7.0 +
Date posted
12 April 2011
Last updated
13 April 2011
Recursive function

Author Info
 Marcelo Piñeyro

3 functions

Average Rating None



Function overview


AgeCalculation  ( dateOfBirth;   dateToCompare )





Tags:  Date   Age  

Calculates how old a person or a thing was, is, or will be on a user-defined date, based on the date of birth of the person or thing.


Sample input

AgeCalculation( Date( 4 ; 12 ; 1980 ) ; "" )

Sample output

31 (when the current date is April 12, 2011 for example)


Function code


Created by Marcelo Piñeyro, Wingra Consulting LLC,
Date created: December 2010
Date modified: April 2011

To calculate how old a person or a thing was, is, or will be on a user-defined date, based on the date of birth of the person or thing.

dateOfBirth: self explanatory. Type: Date.
dateToCompare: the date on which you want to know how old the person or thing was, is, or will be. If left empty it defaults to the current date. Type: Date.

No dependencies

AgeCalculation( Date( 4 ; 12 ; 1980 ) ; "" ) returns 31 when the current date is April 12, 2011 for example.

The returned value is an integer that represents the number of full years of age.

Let( [
    today = If( IsEmpty( dateToCompare ) ; Get( CurrentDate ) ; dateToCompare ) ;
    currentYear = Year( today ) ;
    dateOfBirthMonth = Month( dateOfBirth ) ;
    dateOfBirthDay = Day( dateOfBirth ) ;
    dateOfBirthYear = Year( dateOfBirth ) ;
    bDayThisYear = Date( dateOfBirthMonth ; dateOfBirthDay ; currentYear )
] ;
    IsEmpty( dateOfBirth ) ; "" ;
    today ≥ bDayThisYear ; currentYear - dateOfBirthYear ;
    currentYear - dateOfBirthYear - 1

// ===================================

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit

    Prototype: AgeCalculation( dateOfBirth; dateToCompare )
    Function Author: Marcelo Piñeyro (
    Last updated: 13 April 2011
    Version: 2.0

// ===================================



12 April 2011

This one looks very promising.
If I can suggest something :
- why 3 parameters to pass a date ? All 3 are mandatory, so you could have a simple Date parameter.
- on the contrary, you could add one for the reference date, instead of using the current date. It is often interesting to know what age will someone be at a given (future) date.
  General comment
Marcelo Piñeyro
13 April 2011

Fabrice, thank you for your comments. You are right regarding using 3 parameters to pass a date. I did it that way because in the solution where I originally created the custom function, my client wanted to have a field for day, a field for month, and a field for year, with their respective value lists, but really all that is needed to pass the date of birth into the function is 1 parameter.

I also liked your suggestion to make the function more flexible in terms of being able to determine the age on any given date, not just on the current date. I did think about that before posting the function, but I wasn't sure that anyone would care about it. Your comment encouraged me to implement this feature!

I have uploaded a new version of the function that incorporates both things discussed above.

  General comment






Top Tags

Text Parsing  (32)
List  (30)
Date  (26)
XML  (24)
Format  (23)
Sql  (22)
Dev  (19)
Debug  (16)
Layout  (15)
Interface  (15)
Text  (13)
Variables  (12)
Filter  (11)
Layout Objects  (11)
Design  (10)
Array  (7)