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.
François
François
Assuming the birthdate is in $MyDate, the number of whole years (age) is returned as a number by this action code:
$MyNumber=years($MyDate,date("today"));
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
$MyString=“24.03.1834”;
$MyDate=date($MyString);
$MyNumber=years($MyDate,date(“today”));
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,
François
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:
$MyDate=date("24.03.1834");
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 !
François
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!
A possibly-useful summary:
winken;blinken:nod:
days($Modified,$Created)
$Created.year