Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Calculate age

Questions related to using nuBuilder Forte.
Post Reply
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

Calculate age

Unread post by GlenMcCabe »

I need to calculate age from date of birth input. Any help appreciated.
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 11 times
Been thanked: 18 times

Re: Calculate age

Unread post by Janusz »

If you like nuBuilder, please leave a review on SourceForge
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 11 times
Been thanked: 18 times

Re: Calculate age

Unread post by Janusz »

or with mysql
https://stackoverflow.com/questions/577 ... sql-innodb

you can use on edit form Display field for example:
and for initial trial you can place directly in the Display -> Display/SQL field following code from above link:

Code: Select all

SELECT TIMESTAMPDIFF(YEAR, '1970-02-01', CURDATE()) AS age
(here you can refer to any table values from your DB)

you can place the following in the browse table display inside brackets():

Code: Select all

(SELECT TIMESTAMPDIFF(YEAR, '1970-02-01', CURDATE()) AS age)
or with reference to your data ex:
(SELECT TIMESTAMPDIFF(YEAR, cut_birth, CURDATE()) AS age)
If you like nuBuilder, please leave a review on SourceForge
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

Re: Calculate age

Unread post by GlenMcCabe »

Thanks Janusz.

Will try these
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: Calculate age

Unread post by kev1n »

Pros and cons (Display Object vs JavaScript)

Display Object:

[-] Is only refreshed after the form is saved
[+] It's easy to use

Using JavaScript:

[+] Age can be calculated at any time, even before the form is saved.
[-] Need JavaScript knowledge, maybe a date conversion nevessary.
Post Reply