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

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How can I calculate the user Age based on a sql DATE datatype without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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

We are here to answer your question about How can I calculate the user Age based on a sql DATE datatype - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji