I have a dataframe with two columns 'time1' and 'time2' with the format : "hh:mm:ss"
I want to create a new column that is the difference between 'time1' and 'time2'.
I have tried this :
df.withColumn("diff",
datediff(
to_timestamp($"time1", "hh:mm:ss"),
to_timestamp($"time2", "hh:mm:ss")
)
)
But it always return 0 for diff. What is the correct way to do this ?
data sample :
time1, time2
05:35:30, 05:35:12
07:30:55, 02:39:10
08:35:30, 09:36:10
04:35:30, 05:33:50