Newbies Frosty Posted July 7, 2005 Newbies Share Posted July 7, 2005 I am trying to use the DOB to work out the age from the current date I can't seem to get it right!! For example [color:"red"]DOB (6/22/1988) = 17 Yrs, 0 Mths, -16 Days is not right! The calculation I am playing with is as below [color:"blue"](Year(Today) - Year(Date of Birth) - If((Today) < Date(Month(Date of Birth), Day(Date of Birth), Year(Today)), 1, 0)) & " Yrs, " & (Mod(Month((Today)) - Month(Date of Birth) + 12 - If(Day((Today)) < Day(Date of Birth), 1, 0), 12)) & " Mths, " & (Today- Date(Month((Today) - (Day(Date of Birth) > Day(Today))), Day(Date of Birth), Year(Today))) & " Days" Any help will be gratefully accepted [color:"red"] Link to comment Share on other sites More sharing options...
RalphL Posted July 7, 2005 Share Posted July 7, 2005 In the last year there have been over 100 posts on this subject. Search for + " Age " I am not happy with any of the many calculations. Link to comment Share on other sites More sharing options...
Lee Smith Posted July 7, 2005 Share Posted July 7, 2005 Hi Ralph, I am not happy with any of the many calculations. LOL, is that because they spell out how old you are. [color:"blue"]Hi Frosty, I noticed that the one you posted uses the Today Function, It isn't the function of choice for this type of calculation. This one seems to work. NumToText(Year(Status(CurrentDate)) - Year(DoB) - If(Status(CurrentDate)< Date(Month(DoB), Day(DoB), Year(Status(CurrentDate))), 1, 0)) & " Years, " & NumToText(Mod(Month(Status(CurrentDate)) - Month(DoB) + 12 - If(Day(Status(CurrentDate)) < Day(DoB), 1, 0), 12)) & " Months, " & NumToText(Day(Status(CurrentDate)) - Day(DoB) + If(Day(Status(CurrentDate)) >= Day(DoB), 0, If(Day(Status(CurrentDate)-Day(Status(CurrentDate))) < Day(DoB), Day(DoB), Day(Status(CurrentDate)- Day(Status(CurrentDate)))))) & " Days" HTH Lee Link to comment Share on other sites More sharing options...
RalphL Posted July 7, 2005 Share Posted July 7, 2005 Hi Ralph, LOL, is that because they spell out how old you are. Lee That is only part of it. Most of them have major flaws. Like going from Jan 31 to Feb 28 or 29 if leap year gives 0 months and 28 or 29 days while going from Jan31 to Mar 1 gives 1 month and 1 day. You get this in all short months. I like Jason's the best. Link to comment Share on other sites More sharing options...
Newbies Frosty Posted July 8, 2005 Author Newbies Share Posted July 8, 2005 Hi Lee, This did the trick! Thank you very much for your time and expertise MUCH Appreciated! I love this program it is so much easier to use than Access! Link to comment Share on other sites More sharing options...
comment Posted July 8, 2005 Share Posted July 8, 2005 going from Jan 31 to Feb 28 or 29 if leap year gives 0 months and 28 or 29 days while going from Jan31 to Mar 1 gives 1 month and 1 day. That is not a flaw of the calculation. If Jan 1 to Feb 1 is a full month, then so is Jan 28 to Feb 28. It stands to reason then, that Jan 31 to Feb 28 must be less than a month. The real problem is mixing units that do not mix well. Objectively, there is no such thing as "age in years, months and days". One has to make some arbitrary assumptions to construct such a beast, and it will always be wrong under different assumptions. Link to comment Share on other sites More sharing options...
Newbies gbdoc Posted July 10, 2005 Newbies Share Posted July 10, 2005 Using FMP 7 on Mac Jaguar, I tried Lee's solution (above) with no luck: the "NumToText" function no longer exists in this version (except for Japanese!!!) (I, too, seem to recall having it on earlier FMP versions) . While I have found an accurate calculation for age in years only, I still can't do years, months, and days. I'm new to this forum, and I also haven't been able to find the solution by Jason, referred to by RalphL. As much as I like FMP, it's really upsetting that it's so hard to calculate this, and that they haven't simply made this a function (or a number of functions for elapsed time). Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
Lee Smith Posted July 10, 2005 Share Posted July 10, 2005 Status was changed to Get in v7 GetAsText ( Year(Get(CurrentDate)) - Year(Dob) - If(Get(CurrentDate)< Date(Month(Dob); Day(Dob); Year(Get(CurrentDate))); 1; 0)) & " Years, " & GetAsText(Mod(Month(Get(CurrentDate)) - Month(Dob) + 12 - If(Day(Get(CurrentDate)) < Day(Dob); 1; 0); 12)) & " Months, " & GetAsText(Day(Get(CurrentDate)) - Day(Dob) + If(Day(Get(CurrentDate)) >= Day(Dob); 0; If(Day(Get(CurrentDate)-Day(Get(CurrentDate))) < Day(Dob); Day(Dob); Day(Get(CurrentDate)- Day(Get(CurrentDate)))))) & " Days" I think I saw a better calculation for v7, here, I'll try and find it and post a link later. Lee Link to comment Share on other sites More sharing options...
Newbies gbdoc Posted July 10, 2005 Newbies Share Posted July 10, 2005 and . Lee, you're a gentleman and a scholar! Many, many thanks - I've been fooling with this on and off for weeks! George Link to comment Share on other sites More sharing options...
Newbies gbdoc Posted July 11, 2005 Newbies Share Posted July 11, 2005 To add just a little more: FM's own KB (which I couldn't connect to yesterday) provided the following formula (at Calculating Elapsed Time Between Two Dates Broken Into Year, Month, And Day ). At age around 65, FM's formula makes someone the same age as Lee's formula. If you really get obsessive, as I did, and replaced what FM calls a year in their formula, 365.25 days, with what I found on the web, 365.242199, which also shortens the average length of a month to 30.4368499, the difference is 1 day older (over a span of 65+ years) according to the FM formula. George Link to comment Share on other sites More sharing options...
comment Posted July 11, 2005 Share Posted July 11, 2005 Well, the question how many AVERAGE years and/or months have elapsed between two dates is very different from the question how many ACTUAL years and/or months have elapsed on the calendar. BTW, 365.242199 days is the average length of the tropical year - the average Gregorian calendar year length is 365.2425 days. Link to comment Share on other sites More sharing options...
Newbies gbdoc Posted July 11, 2005 Newbies Share Posted July 11, 2005 Well, the question how many AVERAGE years and/or months have elapsed between two dates is very different from the question how many ACTUAL years and/or months have elapsed on the calendar. How does this affect the FM calculations above? To what extent is the difference of practical significance? BTW, 365.242199 days is the average length of the tropical year - the average Gregorian calendar year length is 365.2425 days. So which number is more appropriate for FM calculations? In any case, it would seem that 365.25 is inaccurate, and should not be used. Right? George Link to comment Share on other sites More sharing options...
comment Posted July 11, 2005 Share Posted July 11, 2005 The practical significance of the difference depends on the purpose of the calculation. Being one day off may be insignificant when compiling the workforce statistics; it can be disastrous when calculating individual birthdays. The same applies to the length of the average year/month. There are no correct answers here. It all depends on what are you trying to accomplish. For example, in the period between 1904 to 2100 the average calendar year is indeed 365.25 days, so if you're trying to approximate the calendrical result in this range, 365.25 might be more appropriate. In an astronomical context, 365.242199 would be much better. The bottom line is that Earth's rotation around its axis is not synchronized to Earth's revolution around the Sun - not to mention the Moon. Filemaker COUNTS in days, and is AWARE of calendar months and years. It cannot translate x days into y months/years, because each month/year has its own length in days. This is NOT like converting inches into centimeters. The phrase "age in years, months and days" is as meaningful as "length in miles, footsteps and rubber bands". Link to comment Share on other sites More sharing options...
Newbies gbdoc Posted July 11, 2005 Newbies Share Posted July 11, 2005 Now I think I understand. It seems to boil down to a difference between scientific accuracy and convention. The former isn't practical for most everyday use, and the convention is practical and accurate enough. Thanks, comment, for taking the time. I've learned good things from you and Lee. Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 6998 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