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 ( date1 ; date2 )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.0  (88 votes)
  Discuss this Custom Function

Winfried Huslik, Huslik Verlag GmbH
http://fmdiff.com

Calculates the number of years, months, and days between any two dates

Sample Input:
age ("7/27/1980" ; "7/26/2006" )
Sample Output:
25
10
30
25 years, 10 months, and 30 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:

This calculation takes into account different days in a month as well as leap years and negative distances. The result is provided as a line separated list containing Years, Months, Days. To access these results use LeftValues (), MiddleValues (), and RightValues () respectively. Use at your own risk.
<br />This formula is meant as a replacement for the one given at <a href="http://filemaker.custhelp.com/cgi-bin/filemaker.cfg/php/enduser/std_adp.php?p_faqid=5532&p_created=1129657697&p_sid=-ERH76bi&p_lva=&p_li=&p_topview=1">FileMaker Custom Help</a><br />
Address comments to agecalc@fmdiff.com.<br />Download an example file at <a href="http://fmdiff.com/fm/agecalc.html">http://fmdiff.com/fm/agecalc.html</a>.

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 10 comments

Function seems to work dandy! One minor quibble is that the fourth value output always assumes a plural value (i.e. "1 Days"). To fix that, you can change the last output line to:

y & " year" & If(y = 1; ""; "s") & ", " & m & " month" & If(m = 1; ""; "s") & ", and " & d & " day" & If(d = 1; ""; "s") & ¶

Regardless, I rated this function 5 / 5.

HazMatt, Blaine, MN USA
March 29, 2013 2:25pm

Awesome Calculation. You can also try
http://help.filemaker.com/app/answers/detail/a_id/5532/kw/todays%20dat e%20function/session/L3RpbWUvMTM2Nzg5OTc1NC9zaWQvT3h5cl95cGw%3D

Full Age
FullAge (calculation, text result) =
GetAsText ( Year ( Get ( CurrentDate ) ) - Year ( Birthdate ) - If ( Get ( CurrentDate ) < Date ( Month ( Birthdate ) ; Day ( Birthdate ) ; Year ( Get ( CurrentDate ) ) ) ; 1 ; 0 ) ) & " Years, " & GetAsText ( Mod ( Month ( Get ( CurrentDate ) ) - Month ( Birthdate ) + 12 - If ( Day ( Get ( CurrentDate ) ) < Day ( Birthdate ) ; 1 ; 0 ) ; 12 ) ) & " Months, " & GetAsText ( Day ( Get ( CurrentDate ) ) - Day ( Birthdate ) + If ( Day ( Get ( CurrentDate ) ) ≥ Day ( Birthdate ); 0 ; If ( Day ( Get ( CurrentDate ) - Day ( Get ( CurrentDate ) ) ) < Day ( Birthdate ) ; Day ( Birthdate ) ; Day ( Get ( CurrentDate ) - Day ( Get ( CurrentDate ) ) ) ) ) ) & " Days "

Ganesh, Carmel, CA
May 06, 2013 9:33pm

Just saw this on a post at fmlayouts.com (unrelated to the age calculation issue) but the post by loSTaNT had a file that had an awesome age calculation field that works and is much simpler as well. You can download the file at: http://fmlayoutmode.com/wp/?p=1356

and the referenced calculation field is:
Let ( [
@cd = Get ( CurrentDate )
; @cdConverted = Year ( @cd ) + Month ( @cd ) / 100 + Day ( @cd ) / 10000
; @bdConverted = Year (Birthdate ) + Month (Birthdate ) / 100 + Day (Birthdate ) / 10000
] ;

Int ( @cdConverted - @bdConverted )

)

Ganesh, Carmel, CA
May 31, 2013 9:19am

It works and I'm happy with the function.

a) Accuracy - I've tested it against "FullAge (calculation, text result)" mentioned in this discussion by Ganesh on May 6 2013. The two agree most of the time. Sometimes there's a day's difference. I assume that's because there's room for defining a month as 30/31 days.

b) Absolute Value - The "FullAge (calculation, text result)" will give a negative number if you swap the dates around. This function age ( date1 ; date2 ) always assumes you want a positive figure.

c) Parameters - I like that it passes back info as 4 separate parameters : Y,M,D,Sentence

d) Singular/Plural - Make this adjustment to the last part of the calculation. It ensures that if there is one day/month/year that system returns "month" instead of "months":
y * neg & ¶ &
m * neg & ¶ &
d * neg & ¶ &
y & If (y = 1; " year, " ;" years, " )&
m & If (m=1; " month & ";" months & " )&
d & If (d=1;" day";" days" ) & ¶

KevinSmith, London UK
January 22, 2014 7:55am

I brought it over as is, and then made a duplicate, named it age_abbreviated, and changed the output to:

y * neg & " Y, " &
m * neg & " M, " &
d * neg & " D"

So output goes to something like "34 Y, 3 M, 13 D" which fits nicer into the field I set up.

Very appreciative of this function!

Dave, Birmingham, AL
June 18, 2015 2:23pm

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 + 9 =
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