Shopping Cart

Search:

Signup

Contact

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

# FileMaker Pro Custom Functions

Months_Diff ( date1 ; date2 )

Rate this function:

Discuss this Custom Function

Ron Smith, PaperCutPro
http://www.papercutpro.com

Months difference part between two dates.

Sample Input:
 Months_Diff ( 7/14/1958 , 4/15/2015 )
Sample Output:
 9

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

## Description:

This is the months difference between two dates which should be entered in with the earlier date first. Ex:

7/14/1958 - 9/8/2006 = 48years 6months 11days

This function could use similar coding as in my Days_Diff function which allows dates in no particular order.

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:

Not sure how this meets anyones needs but the months difference between dates should take in to account the years. Even the sample input shown and output shown is not accurate. I am looking for the true number of months between 2 dates. Take a look at result in that 48 years 6 months and 11 days. Years are irrelevant in that it is a constant 12. July to September is not 6 months no matter how many leap years there are.

Aaron Beck, Lees Summit
July 22, 2013 12:32pm

It makes a great deal of difference when I am checking children and I need their years, month, and days. I use the three together and have for years in my custom EMR.

Warmest regards,

Ron

Ron SMith, McDonough, GA
July 22, 2013 1:28pm

This works to get true months touched between the two dates:

Abs(Case(
Year(Date2)=Year(Date1); If(Month(Date2) <> Month(Date1);1) + Abs(Month(Date2) - Month(Date1));
Year(Date2)>Year(Date1); 0 + If((GetAsDate(Date1))<GetAsDate(Date2); 1 + Months_Diff(Date ( Month(GetAsDate(Date1)+31) ; 1 ; Year(GetAsDate(Date1) +31) ); Date2));
Year(Date2)<Year(Date1); 0 + If((GetAsDate(Date2))<GetAsDate(Date1); -1 - Months_Diff(Date ( Month(GetAsDate(Date1)-31) ; 1 ; Year(GetAsDate(Date1) -31) ); Date2))

))

Aaron Beck, Lees Summit
July 22, 2013 1:30pm

The following formula is directly from the FileMaker help archive...

(Year(Date2 + 1) - Year(Date1 + 1)) * 12 + (Month(Date2 + 1) - Month(Date1 + 1)) - If (Day (Date2 + 1) = Day (Date1), 0, If (Day (Date2 + 1) < Day (Date1+1), 1, 0))

Tom Guise, Droitwich Spa
April 15, 2015 5:22am

Hi, Aaron. There appears to be a typo in that example output. I checked the code and it does work and is correct. I'll fix the example. I apologize for that error. Here is what I get when I look at my information in my EMR at this moment:

My date of birth: 7/14/58
Today's date: 4/15/2015

This calculates to 56 years 9 months 1 day.

Now each of the days and months and years function to give you what you need for years, months, and days. For me in Pediatrics, for example, I must know that a child is 12 months to the day before I give the MMR or it won't count and they'll have to get that first vaccine again.

Use the parts that you need, but I use the three together.

Warmest regards,

Ron Smith, MD

Ron Smith, McDonough, GA
April 15, 2015 6:41am