Skip 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.

Number of months difference

Featured Replies

Hi, How do I do a calculation for the number of month between 2 dates

Thanks

Simon

Script

Set Field [

Calculation questions should go in the Define Fields forum, but here are two possible solutions:

Month(DateTo) - Month(DateFrom)

or

Truncate((DateTo - DateFrom / 30, 0)

Depends on how you define "number of months between".

Ender said:

Month(DateTo) - Month(DateFrom)

Oops, This does not work if dates are from different years.

Hi Ender,

I like your calculations, but I had to modify this one,

Ender said:

Truncate((DateTo - DateFrom / 30, 0)

to this to get it to work:

Truncate((Next Payment Due - Payment Date) / 30, 0)

???

((Year (DateTo) - Year (DateFrom)) * 12 ) + Month (DateTo) - Month (DateFrom)

I'm reluctant to use any date calculations that assume a month is 30 days or a year is 365; it's hard-coding errors and inaccuracies into the system.

FMP has date functions that can work all this stuff out correctly, automatically taking into account leap years and other vagaries of the calendar.

My thought on that was getting an answer to this:

DateFrom: 2/15/2004

DateTo: 4/1/2004

One might say only "1 month" had passed during that period, because we tend to truncate when we talk about duration (I say I'm 30 years old, not 30.5) But of course you are correct to take into account different length months. If the dates are:

DateFrom: 2/15/2004

DateTo: 3/15/2004

The result should be "1 month". My calc did not take this into account.

Oops, I have a typo in my calculation in the script

Lee Smith said:

Script

Set Field [

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.