November 8, 200025 yr I have a date field that contains the birth date for students. I want to create a field that will calculate the birth age for these students. Does anyone know of a calculation that would let me do this? I guess I also need to account for leap years. Thanks!
November 9, 200025 yr Avoid using the Today function, it only recalculates itself at program launch, which means the database has to be closed and reopened every 24 hours for it to be accurate. Use Status[CurrentDate] and Status[CurrentTime] instead, as Chuck suggested.
November 9, 200025 yr quote: Originally posted by dspires: where dob is date of birth: Truncate((Today-dob)/364.25,0) 364.25 won't work exactly. The length of an astronomical year (the time for the earth to complete an orbit around the sun) is 365.242 days. Using such a calculation with that number might work. I'm afraid that I would have to think more on it to know. Chuck [This message has been edited by Chuck (edited November 08, 2000).]
November 9, 200025 yr I agree with avoiding the Today function in situations where the computer is constantly running, but I doubt that being off a day in 125 years matters for a typical student. Even so, the calculation would be: Truncate((Status(CurrentDate)- dob)/365.242,0) [This message has been edited by dspires (edited November 08, 2000).] [This message has been edited by dspires (edited November 08, 2000).]
November 9, 200025 yr Do you just want the whole number of years? If so, try this: Year( Status( CurrentDate ) ) - Year( Birth_Date ) - ( Status( CurrentDate ) < Date( Month( Birth_Date ), Day( Birth_Date ), Year( Status( CurrentDate ) ) ) ) This first calculates the age given the current year minus the year of the Birth_Date. If the birthday has occurred in the current year already, we are fine. If not, subtract 1. Chuck
December 18, 200025 yr I work for a college in Manchester UK and we have a field that calculates the age down to the number of days. NumToText(Year(Today) - Year(Date of Birth) - If(Today< Date(Month(Date of Birth), Day(Date of Birth), Year(Today)), 1, 0)) & " Years, " & NumToText(Mod(Month(Today)-Month(Date of Birth)+12-If(Day(Today) < Day(Date of Birth), 1, 0), 12)) & " Months, " & NumToText(Day(Today) - Day(Date of Birth) + If(Day(Today) >= Day(Date of Birth), 0, If(Day(Today- Day(Today)) < Day(Date of Birth), Day(Date of Birth), Day(Today- Day(Today))))) & " Days" I hope this makes sense and helps.
Create an account or sign in to comment