Age calculation

(Paul) #1

Is it possible (available) - and if yes how - may I automate the calculation of a person’s age by seizing its birth date ?
Thanks for your answer.


(Mark Anderson) #2

Assuming the birthdate is in $MyDate, the number of whole years (age) is returned as a number by this action code:


(Paul) #3

Thank you very much for your answer.
However I do not reach the desired result.
I have created a “new user attribute”, of type “number” and written
in its “Description”, but probably it’s not what is needed, while the return number is wrong.
Could you help me a bit more ?

Cordially yours,

(Mark Anderson) #4

For me, $MyNumber is 184 (years). The only amendment I made to your code was to ensure all the double quotes were straight " and not ‘curly’ or .

Your first two lines can be written as one:


Interestingly, on my UK locale system Tinderbox still correctly parsed out 24 March 1834 as the date, even though in my locale that is normally written 23/03/1834.

I ran the code as a edict, but you could use a rule. If you are looking at the result as a ket attribute of the note being acted on, you may need to de-reselect the note to refresh the KAs.

Here is the result I see:


(Paul) #5

It’s OK !
I got it now
Thank you very much Mark !

Sincerely yours.