calculate age from year of birth

There are two ways:

via php

## 2. in php
You can also use php code, as in the following way
(inspired from this page (, and _slighty modified_: 

    $dob =”$row[anno_nascita]”;
    $age = date_diff(date_create($dob), date_create(‘now’))->y;
    echo “age: $age years

via mysql in phpmyadmin this sql query:
     select *,year(CURDATE())-year(anno_nascita) age from studenti__classi; 
2. save the result as view
3. and so you will have, in the view, the age (of your students, i.g.) that can work in LibreBase (to connect with that view).

Lascia un commento

Il tuo indirizzo email non sarà pubblicato.