TIMESTAMPDIFF
Returns the difference between two DATE or DATETIME in a specific unit of measurement
TIMESTAMPDIFF(unit, datetime1, datetime2)
unit
The unit of measurement in which to return the difference between the values.
datetime1
The value to be subtracted from datetime2
datetime2
The value from which datetime1 will be subtracted
Examples
SELECT TIMESTAMPDIFF(YEAR,'2012-06-12','2022-12-05');
SELECT TIMESTAMPDIFF(DAY,'2022-06-12','2022-12-05');