Skip to main content

How to Calculate Age From Date of Birth in SQL?

Below:

SELECT DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),'DATE_OF_BIRTH')), '%Y') 

 + 0 AS age FROM 'table_name' WHERE condition; 


Source : Click here

Comments

Popular posts from this blog

How to edit or update Table values in HTML webpage using php

 How to edit or update Table values in HTML webpage using php update.php <!DOCTYPE html> <html> <head> <title>Edit/Update Data</title> </head> <body> <?php include_once('config.php'); //Fetching all data (rows or tuples) from the student_details table $roll_no = $_GET['id']; $query = "SELECT * FROM students_details WHERE roll_no=$roll_no"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $name= $row['name']; $email = $row['email']; $address = $row['address']; $phone_number = $row['phone_number']; ?> <h1 align="center">Edit/Update Data</h1> <form action="config.php" method="POST"> <table border='1px' align="center" style="width:90%;">          <tr>             <th>Roll No</th>             <td>                 <input type="text" name="roll_n...

How to view Table values in HTML webpage using php

 How to view Table values in HTML webpage using php Use the code below to view the table data. view.php <!DOCTYPE html> <html> <head> <title>View Data</title> </head> <body> <?php include_once('config.php'); //Fetching all data (rows or tuples) from the student_details table $query = "SELECT * FROM students_details"; //Executing the query $result = mysql_query($query); ?> <h1 align="center">View Data</h1> <table border='1px' align="center" style="width:90%;">          <tr>             <th><center>Roll No</center></th>             <th><center>Name</center></th>             <th><center>Email</center></th>             <th><center>Address</center></th>       ...