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.

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

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

hi,

I try all of them but have a problem with the February 29 and of course, at the end there is a problem

M Boucher, France
March 20, 2018 3:14am

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 9 + 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. HexUUIDToNum_cf (_uuid)
  (Sat, Jun 16, 1:55pm)
2. httpResponseCode ( responseHeaders )
  (Tue, Jun 12, 10:40pm)
3. FindDuplicateCharacters ( string )
  (Fri, Jun 08, 5:01pm)
4. FieldRepetitionLast ( field ; maxRepetition )
  (Wed, Jun 06, 6:05pm)
5. CountModifiedRecords ( NameTimestampField ; StartTimestamp ; EndTimestamp )
  (Mon, May 28, 8:23am)
6. JSONArrayLength ( JSONArrayStr )
  (Fri, May 25, 7:46am)
7. interpolation (y1; y2; y3; x1; x2; x3; x1y1; x2y1; x1y2; x2y2; rnd)
  (Sat, May 19, 3:55am)
8. @JSONFormatElements ( json )
  (Tue, May 15, 3:31am)

RSS Feed of Custom Functions