Page 1 of 1
Calculate age from date of birth in calculated field
Posted: 2020-06-12 10:38
by SkayyHH
Hello,
maybe someone can give me a code for a "calculated field" on how to calculate an age from a date of birth. I tried different Selects, but unfortunately they don't work in the AppGini field "Calculated field.
Thank you very much, Kai
Re: Calculate age from date of birth in calculated field
Posted: 2020-06-12 14:36
by G Belgrado
Re: Calculate age from date of birth in calculated field
Posted: 2020-06-12 22:01
by SkayyHH
Hi,
Thanks a lot. I've already looked at the site. but I have no idea what to put in the "Calculated field".
These codes are for hooks. But what of that comes in the "calculated field" field in the appgini ide?
My fields are: "date_of_birth" and "age"
Thanks very much, Kai
Re: Calculate age from date of birth in calculated field
Posted: 2020-06-14 08:22
by pbottcher
Hi,
you can try
Code: Select all
select TIMESTAMPDIFF(year,date_of_birth,NOW()) as age from YOURTABLENAME where id=#ID#
assuming your pk is id
Re: Calculate age from date of birth in calculated field
Posted: 2020-06-14 15:56
by SkayyHH
Hi,
thank you so much for help
I tried it out. But the code has no effect on the "age" field.
select TIMESTAMPDIFF(year,date_of_birth,NOW()) as age from Employees where id=#ID#
The field names should be correct
Re: Calculate age from date of birth in calculated field
Posted: 2020-06-14 18:52
by pbottcher
Hi,
can you post a screenshot of your tabledefinition and what you put into the calculated field.
Re: Calculate age from date of birth in calculated field
Posted: 2020-06-14 18:57
by pbottcher
Hi, sorry, I just saw a typo in the code.
Try
select TIMESTAMPDIFF(year,date_of_birth,NOW()) as age from Employees where id=%ID%
Re: Calculate age from date of birth in calculated field
Posted: 2020-06-14 19:43
by SkayyHH
Awesome!!!
Many thanks!
Kai