From the following table, my goal is to fill in the value in the column "clmnTimeDiff". Suppose that I have clmnTime1 and clmnTime2, which store the value of "TIME" in string, I want to let the field clmnTimeDiff store the difference between clmnTime2 and clmnTime1. From this table, in the record ID = 1, the result in clmnTimeDiff should be 23:14:31 - 12:15:47 = hh:mm:ss. Actually, the full table contains clmnDate1 and clmnDate2 as well. Previously, I thought that I can follow this query:
SELECT
ID
,clmnTime1
,clmnTime2
,CONCAT(TIMESTAMPDIFF(HOUR, CAST(CONCAT(clmnDate2, ' ', clmnTime2) AS TIMESTAMP),
CAST(CONCAT(clmnDate1, ' ', clmnTime1) AS TIMESTAMP)),
':'
,TIMESTAMPDIFF(MINUTE, CAST(CONCAT(clmnDate2, ' ', clmnTime2) AS TIMESTAMP),
CAST(CONCAT(clmnDate1, ' ', clmnTime1) AS TIMESTAMP)),
':'
,TIMESTAMPDIFF(SECOND, CAST(CONCAT(clmnDate2, ' ', clmnTime2) AS TIMESTAMP),
CAST(CONCAT(clmnDate1, ' ', clmnTime1) AS TIMESTAMP))) AS clmnTimeDiff
FROM example_table
The problem is that my Databricks does not support TIMESTAMPDIFF(), so I'm running out of idea to solve this problem. How can I get the value in clmnTimeDiff?