John Chamberlain Posted April 14, 2013 Posted April 14, 2013 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
David Jondreau Posted April 15, 2013 Posted April 15, 2013 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)
doughemi Posted April 15, 2013 Posted April 15, 2013 http://help.filemaker.com/app/answers/detail/a_id/5139/~/calculation-for-elapsed-months
John Chamberlain Posted April 15, 2013 Author Posted April 15, 2013 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.
David Jondreau Posted April 15, 2013 Posted April 15, 2013 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).
John Chamberlain Posted April 15, 2013 Author Posted April 15, 2013 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
doughemi Posted April 15, 2013 Posted April 15, 2013 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.
John Chamberlain Posted April 15, 2013 Author Posted April 15, 2013 Perfect - this is what comes of trying to fit an FMP5 square block into an FMP11 circular slot. Thanks for all your help!
Recommended Posts
This topic is 4297 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