{"id":1467,"date":"2019-10-12T15:55:00","date_gmt":"2019-10-12T13:55:00","guid":{"rendered":""},"modified":"2020-05-12T21:01:10","modified_gmt":"2020-05-12T19:01:10","slug":"calculate-age-from-year-of-birth","status":"publish","type":"post","link":"https:\/\/digitalia.culturanuova.net\/blog\/?p=1467","title":{"rendered":"calculate age from year of birth"},"content":{"rendered":"<p>There are two ways:<\/p>\n<h4>\nvia php<\/h4>\n<p>## 2. in php<br \/>You can also use php code, as in the following way<br \/>(inspired from this page (<a href=\"https:\/\/stackoverflow.com\/questions\/3776682\/php-calculate-age\">https:\/\/stackoverflow.com\/questions\/3776682\/php-calculate-age<\/a>), and _slighty modified_:&nbsp; <\/p>\n<p>&nbsp;&nbsp;&nbsp; $dob =&#8221;$row[anno_nascita]&#8221;;<br \/>&nbsp;&nbsp;&nbsp; $age = date_diff(date_create($dob), date_create(&#8216;now&#8217;))-&gt;y;<br \/>&nbsp;&nbsp;&nbsp; echo &#8220;age: $age years<br \/>\n&#8220;;<\/p>\n<h4>\nvia mysql in phpmyadmin<\/h4>\n<p>1.do this sql query:<br \/>&nbsp;&nbsp;&nbsp;&nbsp; select *,year(CURDATE())-year(anno_nascita) age from studenti__classi;&nbsp; <br \/>2. save the result as <b>view<\/b><br \/>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).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two ways: via php ## 2. in phpYou can also use php code, as in the following way(inspired from this page (https:\/\/stackoverflow.com\/questions\/3776682\/php-calculate-age), and _slighty modified_:&nbsp; &nbsp;&nbsp;&nbsp; $dob =&#8221;$row[anno_nascita]&#8221;;&nbsp;&nbsp;&nbsp; $age = date_diff(date_create($dob), date_create(&#8216;now&#8217;))-&gt;y;&nbsp;&nbsp;&nbsp; echo &#8220;age: $age years &#8220;; via mysql in phpmyadmin 1.do this sql query:&nbsp;&nbsp;&nbsp;&nbsp; select *,year(CURDATE())-year(anno_nascita) age from studenti__classi;&nbsp; 2. save the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/digitalia.culturanuova.net\/blog\/?p=1467\" class=\"more-link\">Leggi tutto<span class=\"screen-reader-text\"> &#8220;calculate age from year of birth&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[565],"tags":[132,133,11,17,58],"class_list":["post-1467","post","type-post","status-publish","format-standard","hentry","category-office","tag-age","tag-birth","tag-mysql","tag-php","tag-phpmyadmin"],"_links":{"self":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1467"}],"version-history":[{"count":2,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1467\/revisions"}],"predecessor-version":[{"id":1968,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1467\/revisions\/1968"}],"wp:attachment":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}