Mar
26
Calculating Ages
Filed Under Bento Tips
It is fairly simple to add a field to a Library which will show you someone’s age. You need to add a Calculation field to your Library and set the formula to be:

The results can be seen below and please note that the image was created on 26 March 2008 which should put the ages into context.

To explain what is happening, here is a breakdown of the formula.
[Today] - [Birthday] simply subtracts the birthday from today’s date. The value returned is in seconds which then has to be converted into years.
This conversion is done by dividing the number of seconds by the number of seconds in a year and the simplest way of working that out is to multiply 60 seconds by 60 minutes by 24 hours by 365.25 days.
Finally, Bento rounds numbers and this has to be taken account of by subtracting 0.5 from the result. This can be more clearly understood if the formula is changed to remove the subtraction of 0.5 and the number of decimal places to show is increased from none to 6:

Here you can see that the first two people are correctly calculated as being 28 whilst the third person is 27 since their birthday is not until tomorrow. However, if the number of decimal places is reduced to zero again Bento rounds the number and 27.997424 becomes 28. This is because Bento’s rounding works by rounding down if the decimal places are below 0.5 and rounding up if they are equal to or above 0.5.
Therefore subtracting 0.5 from the calculation ’shifts’ everything into the right place for rounding. Here’s what the ages look like with the proper formula applied and the results shown to 6 decimal places:

Although the first two records are now showing the age as 27 the decimal portion is over the magic 0.5 threshold so they get rounded to 28 and the last record is below the threshold so stays at 27.
A Problem
There is a problem with all of this however because Bento does not, as of version 1.0v2, automatically update the value of Today once a record has been created. This means that people’s ages will never change. However the calculation can be forced to update itself by simply entering the editing dialogue for the field itself and then closing the dialogue. The editing dialogue can be displayed either by double-clicking on the field in the Fields list or by choosing ‘Edit’ from the ‘Additional Commands’ button below the Fields list.
Comments
7 Responses to “Calculating Ages”
Leave a Reply
Very Useful coz I’m doing a Talents data base for my company.. Thanks a LOT
Is there a way to create a form view of all birthdays in the next, say, 7 days? Can’t get my head around it…
Hi MAx. You can find the answer in this post in the Bento forums.
But there is a problem for years of birth prior to 1941 - get negative number (136 below the actual age). Would love solution.
Kay, it seems to be fine for me and a birthday of 25 March 1938 correctly reports the person as being 70. I wonder, is your system set so that the dates display with two digits for the year rather than four? If so then I would guess that Bento is doing what most applications will do and is using a cut-off to decide whether dates are in the 1900 range or the 2000 range and for Bento it is 41.
Folks
The formula works up to the minus sign and then shows an error. Any ideas?
Try clearing out the Calculation area and starting again. I’ve had cases in the past where Bento doesn’t properly pick-up the use of Today or the Birthday field which breaks the formula. You can also simplify it slightly by making the formula:
(([Today] - [Birthday]) / 31557600) - 0.5
Finally, make sure you have spaces between, well, everything since Bento is is a bit fussy about that.