1 | initial version |
The method to derive age from a birth date in SQLite is as follows:
SELECT strftime('%Y', 'now') - strftime('%Y', birthdate) - (strftime('%m-%d', 'now') < strftime('%m-%d', birthdate)) AS age
Here, the strftime() function is used to extract the year, month, and day from the birth date and the current date. Then, the year difference between the two dates is calculated and adjusted for the birth month and day. Finally, the result is returned as the age.