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

Months_Diff ( date1 ; date2 )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.1  (34 votes)
  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.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

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

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