How can I calculate the user Age based on a sql DATE datatype

So from my SQL query I receive: FRI DEC 13 1991 00:00:00 GMT+0100 (CET) as a date result. But All I want is the current user age in years. Is there anyway to calculate this? Or is there any nom extension I can use? Thanks for your time.

Answer

SELECT DATEDIFF(day,'olddate','recentdate') AS AGE FROM your_table;

The returned value is AGE. Use whatever date format you have but that is the SQL query for your problem

Leave a Reply

Your email address will not be published. Required fields are marked *