simoncpage Posted May 5, 2004 Posted May 5, 2004 Hi, How do I do a calculation for the number of month between 2 dates Thanks Simon
Ender Posted May 5, 2004 Posted May 5, 2004 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 Posted May 5, 2004 Posted May 5, 2004 Ender said: Month(DateTo) - Month(DateFrom) Oops, This does not work if dates are from different years.
Lee Smith Posted May 5, 2004 Posted May 5, 2004 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) ???
Vaughan Posted May 5, 2004 Posted May 5, 2004 ((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.
Ender Posted May 5, 2004 Posted May 5, 2004 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.
Lee Smith Posted May 6, 2004 Posted May 6, 2004 Oops, I have a typo in my calculation in the script Lee Smith said: Script Set Field [
Recommended Posts
This topic is 7510 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now