dadudette Posted September 3, 2006 Share Posted September 3, 2006 Hi all, I've read through all the posts I could find on age calculation and while it sounds like you all know what you're doing, it's leaving me quite confused. My goal is to calculate age in years and months (though I suppose I'd settle for years if need be) using a date of birth. The database I'm trying to make is for a small, non-profit school for kids age 3-12, and at the lower side of that range knowing the kid's age down to the month can be pretty helpful. I realize there are challenges in accomplishing this due to the varying number of days in a month, but I'm hoping someone out there will have a function I can understand. I'm still wet behind my FMPro ears so please use plain English on me!!! Thanks so much for your brainpower and your willingness to share it.... DaDudette Link to comment Share on other sites More sharing options...
dadudette Posted September 3, 2006 Author Share Posted September 3, 2006 One more thing: I have all these fields: DOB MONTH DOB DAY DOB YEAR DOB So if calculating the age in years and months is easier with the separate fields, I'm all for that. I did them separate because I wanted to be able to sort by the birthdays to know which birthdays are in a month for each classroom. Is that of any help at all? I think I'd actually prefer keeping the separate fields for the date of birth instead of the consolidated one. Da Link to comment Share on other sites More sharing options...
comment Posted September 3, 2006 Share Posted September 3, 2006 You would calculate the age is years in Filemaker in the same way as you would in your head: first, subtract today's year from the year of birth; then, if this year's birthday has not occured yet, subtract a year: Year ( today ) - Year ( DOB ) - ( today Calculating the age in months is more problematic because, as you say, the months vary in length. So the question arises: when does a person born on Jan 31 become one month old? There is no single correct answer to this question. It depends on whatever rules you wish to make up. For example, this formula computes the age in months on the assumption that a person becomes a month older on the same day-in-month as his birthday or when the month ends - whichever happens first: 12 * ( Year ( today ) - Year ( DOB ) ) + Month ( today ) - Month ( DOB ) - ( Day ( today ) Alternatively, you could just ignore the problem and compute the age in average months: Div ( today - DOB ; 30.436875 ) Don't use this one to keep track of birthdays, or it can become really embarassing. Link to comment Share on other sites More sharing options...
serena1 Posted October 30, 2006 Share Posted October 30, 2006 I was stuck on this too, and this is the calculation I was given. You need two fileds dob and (in my case) YearStartDate as I needed to calculate pupil ages for the start of the year: If(DayOfYear(dob ) It works! and you can obviously change the YearStartDate whenever you need to calculate a new batch of ages. Serena Link to comment Share on other sites More sharing options...
dadudette Posted February 16, 2007 Author Share Posted February 16, 2007 Hi Serena, and thank you for your help. Your calculation makes total sense to me, but I don't understand which parts of it would change for my own fields (which are DOB MO, DOB DAY, DOB YR). Can you help me understand that? And do I need to create a field for the current date and such, or is that just something fmpro knows? Thank you, Dadudette Link to comment Share on other sites More sharing options...
comment Posted February 17, 2007 Share Posted February 17, 2007 Your calculation makes total sense to me It does? I find it a little odd that a person born on Sep 1, 2000 will be exactly 6 years and 0 months old on their 7th birthday (but jump straight to 7 years and 0 months on the following day). Link to comment Share on other sites More sharing options...
Rui Gonçalves Posted February 26, 2007 Share Posted February 26, 2007 This is what I use, with the help of our Friends from this Forum. Suppose you have a field “Date of Birthâ€, that would be date result; And a Script to calculate Today’s Date; Then a calculation field named "Age", with the following calculation If(IsEmpty(Date of Birth)=1; GetAsDate("");GetAsText(Year(Today) - Year(Date of Birth) - If(GetAsNumber(Today)= Day(Date of Birth); 0; If(Day(Today- Day(Today)) It works for me (Result Expl: 44 Year(s), 5 Month(s) and 10 Day(s)) Link to comment Share on other sites More sharing options...
muzzypatmn Posted April 22, 2007 Share Posted April 22, 2007 I've gotten so far into this problem but haven't as yet figured out how to truncate the age to maybe 1 or 2 decimal points. Using (Get ( CurrentDate ) - DOB:)/365.25 to get close to what I want, but would really like to either drop the decimal positions in the result or just limit it to 1 or 2 decimal points. Anyone got any ideas? Thanks in advance.smiley-smile Link to comment Share on other sites More sharing options...
sujat Posted October 11, 2007 Share Posted October 11, 2007 Age ( Year ) = Year (Date Today) - Year (DOB) - If (Date Today Age ( Month ) = Mod (Month (Date Today) - Month (DOB) + 12 - If (Day (Date Today) Age ( Day ) = Day (Date Today) - Day (DOB) + If (Day (Date Today) >= Day (DOB); 0; If (Day (Date Today - Day (Date Today)) Use merge field or use GetAsText function to display age. Hope this helps. I've gotten so far into this problem but haven't as yet figured out how to truncate the age to maybe 1 or 2 decimal points.Using (Get ( CurrentDate ) - DOB:)/365.25 to get close to what I want, but would really like to either drop the decimal positions in the result or just limit it to 1 or 2 decimal points. Anyone got any ideas? Thanks in advance.smiley-smile Link to comment Share on other sites More sharing options...
Recommended Posts