July 8, 201015 yr A client, given a birthdate, wants to know the age of contacts in Year, Months, and Days. I built a function that I thought covered all the bases, but in testing it I kept getting results I didn't expect. I think the problem is how an age in how I'm defining YMD. I would simply say that a person is x number of years for the years completed, y number of months for the months completed and z number of days. How would you define the age of someone in YMD? Please do a sanity check for me: Today is 3/1/2010. Joe is born on 12/31/85. How old is he? Jill is born on 12/30/85. How old is she? Express ages in Year, Months, and Days.
July 9, 201015 yr Author See (for example): http://fmforums.com/forum/showtopic.php?tid/183910/ OK, I'm not crazy. And I can confidently go back to the client and clarify the issue.
July 9, 201015 yr Author James is born on 2/29/1984 and Jane is born on 2/28/1984: how hold are they ? I don't think that's one of the exceptions... I would say: James is 26 years, 5 4 months, and 10 days. Jane is 26 years, 5 4 months, and 11 days. The issue I've come across is when a person is born on a day in the birth month that doesn't exist in the previous month of the current date. As per my original post. Edited July 9, 201015 yr by Guest
July 9, 201015 yr Just one more note: you CAN express the age in Y,M,D, according to any arbitrary rules you choose. However, no matter which method you follow, the rules of arithmetic difference will not apply to the results. Here are two examples of rules that you cannot expect to hold true: If: a + b = c Then: c - b = a If: a + b = c AND d + b = c Then: a = d
July 9, 201015 yr I don't think that's one of the exceptions... I would say: James is 26 years, 5 4 months, and 10 days. Jane is 26 years, 5 4 months, and 11 days. So Jane is clearly older ( 1 day ) than James. Now, based on your assumption, give me the resut if today is 2/28/2010... They have both completed 26 years, both completed their months...
July 9, 201015 yr Author I'm not sure the point you're trying to make unless it's the same one as my original post.
July 9, 201015 yr Yes, in your original post you said: "I would simply say that a person is x number of years for the years completed, y number of months for the months completed and z number of days" Based on that assumption, on 2/28/2010 they are both 26 years old.
July 9, 201015 yr Here are two examples of rules that you cannot expect to hold true: If: a + b = c Then: c - b = a If: a + b = c AND d + b = c Then: a = d I do not get this one... both rules are true.
July 10, 201015 yr Based on that assumption, on 2/28/2010 they are both 26 years old. Well, then they were born on the same day, according to rule #2.
July 10, 201015 yr Daniele, take a look at this link about non sequitur and scan down to "Affirming the Consequent". The truth of the conclusion is independent of the truth its premises - it is a 'non sequitur'. Edited July 10, 201015 yr by Guest Changed the last sentence.
September 2, 201015 yr Author All right. Finally heard from the client on how they want to define age. The basically want to treat Year, Month, and Date as separate digits and subtract. Months are 30 days and Years are 12 months. Today Year.TodayMonth.TodayDay -BirthYear.BirthMonth.BirthDay _______________________________ Years.Months.Days I solved it ugly: Let([ birthdate = People::Birthdate; today = Get(CurrentDate); bday =Birthdate; error = IsEmpty(bday) ; //Days dToday = Day(Today); dBday = Day(bday) ; dCarry = (dToday < dBday ); dToday = (dToday + (dCarry*30)); days = dToday -dBday; dResult = days & " day" & If(days ≠ 1; "s") & " " ; //Months mToday = Month(Today) - dCarry; mBday = Month(bday); mCarry = (mToday < mBday); mToday = (mToday + (mCarry*12)); months = (mToday - mBday); mResult = months & " month" & If(months ≠ 1; "s") & " " ; //Years yToday = Year(Today) - mCarry; yBday = Year(bday); years = (yToday - yBday); yResult = years & " year" & If(years ≠ 1; "s") & " " ; result = yResult & " " & mResult & " " & dResult; result = Case(error; ""; result) ]; result ) But two things... -I'm sure there's an eleganter way to achieve this result. -The client also want to calculate how many months and days until an pregnant woman's due date. Any thoughts on that? Thanks, DJ Edited September 2, 201015 yr by Guest I should have replied to myself and not LaRetta. Is there a way to delete a post?
September 2, 201015 yr Try: n = Date2 - Date1 ; y = Div ( n ; 360 ) ; m = Div ( Mod ( n ; 360 ) ; 30 ) ; d = Mod ( n ; 30 ) The client also want to calculate how many months and days until an pregnant woman's due date. Any thoughts on that? Same thing - except you don't need the year part, so: m = Div ( n ; 30 ) ; d = Mod ( n ; 30 )
September 2, 201015 yr Author n = Date2 - Date1 ; y = Div ( n ; 360 ) ; m = Div ( Mod ( n ; 360 ) ; 30 ) ; d = Mod ( n ; 30 ) I appreciate the help, but this doesn't give the result for which the client is looking. The formula they use works out like this...If a child was born on June 8th, 2007 and today is September 2nd, 2010: 2010 09 02 -2007 06 08 _______________ 0003y 02m 24d If Day(Today)< Day(BDay); 30 days gets carried over from the months column.
September 2, 201015 yr Or did you perhaps mean: em = 12 * y2 + m2 - 12 * y1 - m1 - ( d1 > d2 ) ; y = Div ( em ; 12 ) ; m = Mod ( em ; 12 ) ; d = Mod ( d2 - d1 ; 30 ) Edited September 2, 201015 yr by Guest
September 2, 201015 yr Author If the day of the birthdate is greater than today's day, we "carry over" 30 days, not the number of days there really are in the previous month. If the birth month (modified by the above carry over) is greater than today's month, a year gets taken off and 12 months are carried over. A better example may be a birthday of June 8th, 2007 and a current date of May 2nd, 2010. 2010y 05m 02d -2007y 06m 08d _______________ becomes 2009y 16m 32d -2007y 06m 08d _____________ = 0002y 10m 24d Does that make sense? This is literally how they've been doing it by hand , "carry the one" or rather "carry the 30".
September 2, 201015 yr Hi 2010 08 31 2010 07 31 ---------- 0y 1m 0d 2010 09 01 2010 07 31 ---------- 0y 1m 0d So there are 2 days where the guy is one month old.
September 2, 201015 yr Author em = 12 * y2 + m2 - 12 * y1 - m1 - ( d1 > d2 ) ; y = Div ( em ; 12 ) ; m = Mod ( em ; 12 ) ; d = Mod ( d2 - d1 ; 30 ) That certainly give the correct results for a few problem dates. I'm going to need a day and a stiff drink to understand what's going on though.
September 2, 201015 yr Author So there are 2 days where the guy is one month old. Yes, I'm aware of that. That's a compromise the client wants to make...and has been making pre-FMP.
September 2, 201015 yr there are 2 days where the guy is one month old. So? I know a woman who was 39 years old for 4 years.
September 2, 201015 yr Then you can try: Let([ n = 360* ( Year ( End ) - Year ( Start ) ) + 30* ( Month ( End ) - Month ( Start ) ) + ( Day ( End ) - Day ( Start ) ) ; y = Div ( n ; 360 ) ; m = Div ( Mod ( n ; 360 ) ; 30 ) ; d = Mod ( n ; 30 ) ]; y & "y " & m & "m " & d & "d" )
Create an account or sign in to comment