There is a table student(birthday,age)
In birthday data from input type="data" are brought
How to calculate the student's age and add age to student in the string?
- so what's the problem? $ age = $ today - $ birthday and INSERT in the database. - nueq
- 2And why do you need age column? its value can always be calculated and so at the time of treatment. What is your DBMS? The functions for working with the date are practically not standardized, and each database has its own - Mike
|
1 answer
in general, as it were 1. Having a date is easy to consider age and how to keep duplicating data is not good. But if you really need age, DATEDIFF will help you, or rather, somewhere like that: select DATE_FORMAT (FROM_DAYS (DATEDIFF (birstday, now ())), '% Y') + 0 AS age , and write the update function to the column in phpmyadmin I I think you can
|