Time database function

What database function is to be used to get the difference between 2 time stamps in minutes?

I have tried using the function - minute(${datetime})

If the in time is 10:17:00 & out time is 10:25:00 the difference between both shows correctly as 8
If the in time is 10:15:00 & out time is 11:25:00 the difference between both shows as 0 instead of 60

What function should be used, such that 11:25:00 - 10:15:00 yields a result of 60?

I also tried creating a view with the following query to get the time difference. The view was created fine in helical & the query works fine in a regular MySQL interface too.

SELECT STUDENT_ID ,IN_TIME,OUT_TIME, TIMEDIFF(OUT_TIME,IN_TIME)
FROM mst_clinical_history

When i drag the student ID & the Time Difference columns, i get the below error.

Error: MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Time.TIMEDIFF(OUT_TIME,IN_TIME) as `Average Visit Time_TIMEDIFF(OUT_TIME,IN_TIME’ at line 2

Anything that can be done to get the correct output?

Hi Hussainac,

To find the difference between two date fields try using create custom column.
In custom column use the function TIMESTAMPDIFF().

Syntax: TIMESTAMPDIFF(MINUTE,DateExp1,DateExp2)
Example: TIMESTAMPDIFF(MINUTE,‘2009-05-18 10:15:00’,‘2009-05-18 11:25:00’)

Date difference