Tinderbox Forum

Age calculation

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.


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


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,

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:


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

Sincerely yours.


1 Like

Has something changed in the interim since this was posted or as is more usual, am I doing something wrong here?

I have an attribute $DOB set to date
I have an attribute $Age set to string

I have an edict: $Age=years($DOB.date("today"));

I get the following:

What am I doing wrong here?

Should the period after $DOB be a comma?

Yes indeed sir, that seems to be the solution! Thank you very much!

1 Like

A possibly-useful summary:

  • ; separates items in sets and lists: winken;blinken:nod:
  • , separates arguments in operators: days($Modified,$Created)
  • . separates an attribute from an accessor: $Created.year