I have query where I have to find the difference between two times , it works well when the first time is greater than the second time .
But when the first one is smaller than the second one it returns a negative time; Just wondering is there any way to make it positive?
Below is the query that returns negative time.
SELECT TIMEDIFF("13:10:11", "13:20:10");
If what you want is to get the absolute time difference between two times, you could use a
CASE expression to swap the times so that the first was always greater than the second e.g.
SELECT CASE WHEN time1 < time2 THEN TIMEDIFF(time2, time1) ELSE TIMEDIFF(time1, time2) END AS delta
Use DateDiff with MINUTE difference:
SELECT DATEDIFF(MINUTE, '11:10:10' , '11:20:00') AS MinuteDiff