Shopping Cart

Search:

Signup

Contact

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

# FileMaker Pro Custom Functions

Elapsed ( StartDate ; EndDate )

Rate this function:

Discuss this Custom Function

Lee Smith, Smith and Associates
none

Elapsed Date to Text

Sample Input:
 Elapsed(EndDate;StartDate) 2/28/2000 and 2/27/2004
Sample Output:
 3 Years 11 Months 29 Days

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

## Description:

that will calculate the elapse time between two dates and convert it to text

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:

Works very well. Slightly trivial but unitary values show as plural e.g. 1 Years, 1 Months etc. But otherwise great.

Nick Stockbridge, Bristol, England
August 04, 2011 2:32am

// Elapsed ( StartDate ; EndDate )
//Calculating Elapsed Time Between Two Dates Broken Into Year, Month, And Day
//Edited to omit empty values, handle singular and plural correctly, and simplify month_length

Let([
Number_of_Days = EndDate - StartDate
; Month_Length = Choose ( Month(StartDate) ; ""; "31"; "28"; "31"; "30"; "31"; "30"; "31"; "31"; "30"; "31"; "30"; "31"
)
; ~y = Int ( Number_of_Days / 365.25 )
; ~y = Case (
~y = 0 ; // Omitted
"" ;
~y = 1 ; // Singular
~y & " Year " ;
// Plural
~y & " Years "
)

; ~m = If((Round( Mod( Number_of_Days ; 30.4375 ) ; 0 )) <= Month_Length and ((Int(Number_of_Days / 30.4375))) < "1" ; 0 ; ((Int(Number_of_Days / 30.4375) - (12 * (Int( Number_of_Days / 365.25 ))))))
; ~m = Case (
~m = 0 ; // Omitted
"" ;
~m = 1 ; // Singular
~m & " Month " ;
// Plural
~m & " Months "
)

; ~d = Round( Mod( Number_of_Days ; 30.4375 ) ; 0 )
; ~d = Case (
~d = 0 ; // Omitted
"" ;
~d = 1 ; // Singular
~d & " Day" ;
// Plural
~d & " Days"
)

];
~y & ~m & ~d
)

Michael Wallace, Dallas, Texas
August 15, 2016 5:51pm