SELECT TIMESTAMPDIFF(YEAR,'2002-05-01','2001-01-01'); : TIMESTAMPDIFF « Date Time Functions « MySQL Tutorial






mysql>
mysql> SELECT TIMESTAMPDIFF(YEAR,'2002-05-01','2001-01-01');
+-----------------------------------------------+
| TIMESTAMPDIFF(YEAR,'2002-05-01','2001-01-01') |
+-----------------------------------------------+
|                                            -1 |
+-----------------------------------------------+
1 row in set (0.00 sec)

mysql>








14.47.TIMESTAMPDIFF
14.47.1.TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2): Returns the integer difference between datetime_expr1 and datetime_expr2
14.47.2.SELECT TIMESTAMPDIFF(FRAC_SECOND,'2003-02-01','2003-05-01');
14.47.3.SELECT TIMESTAMPDIFF(SECOND,'2003-02-01','2003-05-01');
14.47.4.SELECT TIMESTAMPDIFF(MINUTE,'2003-02-01','2003-05-01');
14.47.5.SELECT TIMESTAMPDIFF(HOUR,'2003-02-01','2003-05-01');
14.47.6.SELECT TIMESTAMPDIFF(DAY,'2003-02-01','2003-05-01');
14.47.7.SELECT TIMESTAMPDIFF(WEEK,'2003-02-01','2003-05-01');
14.47.8.SELECT TIMESTAMPDIFF(MONTH,'2003-02-01','2003-05-01');
14.47.9.SELECT TIMESTAMPDIFF(QUARTER,'2003-02-01','2003-05-01');
14.47.10.SELECT TIMESTAMPDIFF(YEAR,'2003-02-01','2003-05-01');
14.47.11.SELECT TIMESTAMPDIFF(YEAR,'2002-05-01','2001-01-01');