Brian Dunning's FileMaker Custom Functions

DateDif ( date1 ; date 2 ; flag )

Simulates Excel function of same name and provides for text labeling with correct grammer.

  Average rating: 4.5 (35 votes) Log in to vote

Brett Buchmiller   Brett Buchmiller
No Company
http://filemaker.com

Share on Facebook Share on Twitter

  Sample input:
DateDif( 11/2/2006 ; 7/6/2011 ; "Y" )

DateDif( 11/2/2006 ; 7/6/2011 ; "T" )

DateDif( 11/2/2006 ; 7/6/2011 ; "LIST" )
  Sample output:
4


4 years, 8 months and 4 days


4
8
4

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Based on the excellent algorithm by Winfried Huslik but adapted for multiple uses based on flag. Works similar to DateDif() function in excel where flag determines if returns years, months or days between dates. Additional flags allow for text string with proper grammer or list of values to be accessed by LeftValues(), MiddleValues() or RightValues.

 

Comments

Daniele Raybaudi   Daniele Raybaudi, ACI
Aug 8, 2011
Hi

what if a date is empty ?
 
Daniele Raybaudi   Daniele Raybaudi, ACI
Aug 8, 2011
What about:

...
d1 = Min ( date1 ; date2 ) ;
d2 = Max ( date1 ; date2 ) ;
...
 
DJ   DJ, NM
Nov 3, 2014
Using the dates 02/01/2015 and 11/30/2015 returns the wrong result.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: