1SELECT TIMESTAMPDIFF(HOUR, '2021-05-22 07:00:00', '2021-05-22 12:00:37') as time_diff_in_hours;
1-- With implicit CAST
2SELECT * FROM my_table
3 WHERE my_date BETWEEN '2021-06-01 01:12:00' AND '2021-06-30 23:59:59';
4-- is EQUIVALENT to
5SELECT * FROM my_table
6 WHERE my_date >= '2021-06-01 01:12:00' AND my_col <= '2021-06-30 23:59:59';
1SELECT TIME_TO_SEC(TIMEDIFF('2021-05-22 12:00:00', '2021-05-22 12:00:37')) as diff_in_seconds;