I suggest extracting the hour and minute and doing the calculation without a built-in function. In short, you can get the minute difference with this:
( HOUR( "EndTime" ) - HOUR( "StartTime" ) ) * 60 + ( MINUTE( "EndTime" ) - MINUTE( "StartTime" ) )
For a formatted ‘hh:mm’ output, this query does a little more work:
SELECT "StartTime", "EndTime",
CONCAT( CONCAT( "hours", ':' ), ( "minutes" - ( "hours" * 60 ) ) ) "DiffTime"
FROM (
SELECT "PriKey", "StartTime", "EndTime", ( HOUR( "EndTime" ) - HOUR( "StartTime" ) ) * 60 +
( MINUTE( "EndTime" ) - MINUTE( "StartTime" ) ) "minutes",
( ( HOUR( "EndTime" ) - HOUR( "StartTime" ) ) * 60
+ ( MINUTE( "EndTime" ) - MINUTE( "StartTime" ) ) ) / 60 "hours"
FROM "Table1"
) AS "subquery"
Alternatively, if your variables are DATETIME
and not just TIME
, you can use the DATEDIFF
function documented in the HSQLDB v1.8 manual.
There are other ways to accomplish this result also, for example, in a Basic
macro.
EDIT: Renamed the fields in the second query to be consistent with the first.
(if this answered your question, please accept answer by clicking check mark () to the left)