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
Calculate age from date of birth in calculated field
-
- Veteran Member
- Posts: 61
- Joined: 2017-03-12 09:24
Re: Calculate age from date of birth in calculated field
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
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
Hi,
you can try
assuming your pk is id
you can try
Code: Select all
select TIMESTAMPDIFF(year,date_of_birth,NOW()) as age from YOURTABLENAME where id=#ID#
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Calculate age from date of birth in calculated field
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
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
Hi,
can you post a screenshot of your tabledefinition and what you put into the calculated field.
can you post a screenshot of your tabledefinition and what you put into the calculated field.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Calculate age from date of birth in calculated field
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%
Try
select TIMESTAMPDIFF(year,date_of_birth,NOW()) as age from Employees where id=%ID%
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Calculate age from date of birth in calculated field
Awesome!!!
Many thanks!
Kai
Many thanks!
Kai