lyalem Posted November 8, 2000 Posted November 8, 2000 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!
dspires Posted November 8, 2000 Posted November 8, 2000 where dob is date of birth: Truncate((Today-dob)/364.25,0)
Vaughan Posted November 9, 2000 Posted November 9, 2000 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.
Chuck Posted November 9, 2000 Posted November 9, 2000 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).]
dspires Posted November 9, 2000 Posted November 9, 2000 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).]
Chuck Posted November 9, 2000 Posted November 9, 2000 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
McGoo Posted December 18, 2000 Posted December 18, 2000 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.
Recommended Posts
This topic is 8812 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