Jump to content
Server Maintenance This Week. ×

Calculating birth age


This topic is 8537 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).]

Link to comment
Share on other sites

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).]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
Share on other sites

This topic is 8537 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.