Skip to main content

FileMaker Custom Function: Calculate Years elapsed

For you FileMaker Pro Advanced users out there...

If you have several date fields and would like to calculate years elapsed (for example a person's age) here is a custom function that will do it.

Of course it is a simple calculation and could be typed each time you need it in a calculation field, but this is designed to be used in several places where needed.

Examples:

  • Age 
  • Years of service since hire date
  • Years married
You get the idea.


/**
 * =====================================
 * YearsElapsed ( startDate )
 *
 * PURPOSE:
 * Convenience function for working with
 * dates to calculate age or years elapsed to current date.
 *
 * RETURNS:
 * (number)
 *
 * PARAMETERS:
 * startDate = Field reference
 *
 * EXAMPLES:
 * YearsElapsed ( dateBirth ) = 46.7
 * YearsElapsed ( dateHired) = 2.7
 *
 * DEPENDENCIES:
 * none
 *
 * NOTES:
 * This is simply a helper function to avoid having excessive amounts of
 * similar code within a FileMaker solution.
 *
 * HISTORY:
 * MODIFIED on Monday, September 16, 2013 by Robert Kuivanen - added
 *
 * REFERENCES:
 * (see YearsElapsed custom function)
 * =====================================
 */

Truncate ( ( Get ( CurrentDate ) - startDate ) / 365.2425; 1 )

Comments

Popular posts from this blog

Calculate Age or Years Elapsed in an Apple Numbers Sheet

Often it is useful to show a person's age or years elapsed since a start date.  For example: Hire Date: 4/1/2012 - Years of service: 1.5 Here's a formula for Numbers that will do the trick: =IF(ISBLANK(cellReference),"",DATEDIF( cellReference ,TODAY(),"D")/365.2425) Replace the cellReference with the actual cell reference. i.e.: (A1)  So here's the breakdown: =IF(ISBLANK(cellReference),""  --- this checks to see if there is a start date in your referenced cell.  For example say your spreadsheet has a cell (A1) that holds a date of birth, but it is not yet referenced, this will result in an empty string. (Blank cell) Otherwise, it calculates the years:  DATEDIF( cellReference ,TODAY(),"D")/365.2425) DATEDIF compares two dates. The first date is your cell reference i.e.: (A1) The second is the current date according to your computer, iOS device: TODAY()  returning the Day -  "D" Then the difference is divi...

Rumor Mill: New mac Mini Coming?

There are reports all over the Internet about a new Mac Mini to be possibly released at MacWorld.  TUAW is reporting that a new version of the Mini will include an optical drive that can be swapped for a second hard drive.  The housing will look much like the Time Capsule with a "lip" for consealing the optical dive slot and cooling. Whether true or not, I would like to see a few features in a new Mac Mini. More RAM (Of course.) NVIDIA chipset. FW port for external HD My main use for a Mini would be for media.  A Mini on my network using Front Row would be great for movies and TV.  (Sorry, Apple TV.)

Opera Acid3 Test

Here is the Opera test.  Performed the best so far.  Interesting.  Any thoughts anyone?