How to calculate the time difference in MySQL?

3

How to calculate the difference of hours in MySQL ?

    
asked by anonymous 18.06.2014 / 15:14

2 answers

4

To calculate the time difference in MySQL use function TIMEDIFF that returns the difference between the hours, along with the function CURTIME() that returns the current time.

Example:

SELECT TIMEDIFF(CURTIME(), hora) as dif 
               FROM conversas WHERE de=7 ORDER BY id DESC LIMIT 1;

References:

18.06.2014 / 15:14
0

Dude I was with the same doubt and it helped me

link

ex .. SELECT TIMESTAMPDIFF (SECOND, open_add, cas_data_data), user_name, cas_status, cas_data_de_opertura, cas_data_de_claramento FROM case INNER JOIN user ON case.usu_id = user.usu_id WHERE cas_status = 'Closed' AND cas_id = 75

    
14.11.2018 / 02:36