Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

I need to calculate the number of months between two dates. Not the number of days, nor the number of years, just the number of months.

 

Can anyone tell a poor old (still thinking in FMP 5) man how to do this?

 

Thanks

Solved by John Chamberlain

Go to solution

This has been discussed before and one issue is how to define "a month". How exact does this need to be and what about the "edge" cases? What are you actually using this for?

 

For your needs, how many months are there between:

March 1st to March 31st (31 days)

March 30th to April 29th (31 days)

April 30th to May 30th (30 days)

January 30th to February 28th (29 days)

February 28th to March 28th (29 days)

  • Author

This does not need to be exact. I would define a "Month" as 30.4375 "days" (365.25/12 days). I need to define the age of cats, eligilbe for adoption, in a shelter.



Also, "edge cases" do not matter.

Well, then subtracting Date1 from Date2 and dividing by 30.5 should be fine.

 

Doug's linked function is ok, but fails in certain situations (eg 2/28/2013 to 3/30/2013 = 0 months).

  • Author

I tried this field definition:

 

= (// -  CAT'S DATE OF BIRTH)/30.4375

 

And I got the following error message:

 

"A number, text constant, field name or "(" is expected here"

 

The cursor is positioned at the end of the definition.



Cat's Date of Birth is defined as MM/DD/YYYY

The shortcut "//" is for display purposes only (as a placeholder for the current date in a text object on a layout).  It doesn't work in a calculation.

 

Use Get(CurrentDate) instead.

  • Author
  • Solution

Perfect - this is what comes of trying to fit an FMP5 square block into an FMP11 circular slot. 

 

Thanks for all your help!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.