I have a MySQL database with a date_of_birth field. The data stored in this field is of the format: MM-DD-YYYY. I need to compute age for this field so I must compare and take the difference of CurDate().
To do this I have written the following:
select FLOOR((DATE_FORMAT(curdate(), '%m-%d-%Y') - date_of_birth)/10000)
from patients
So I would expect it to be comparing the CurDate() of MM-DD-YYYY minus DOB of MM-DD-YYYY. However, for my one test case it continues to return a -1. I've got this working fine with MSSQL but it seems MySQL is a bit more picky/less user friendly.
Am I missing something here? Whats the deal, please help!
Thanks