Question: how to find time difference between two rows in sql?
Answer: select recordid, transdate, cast( (transdate - lag(transdate) over (order by transdate)) as time) as diff from t; In other words, you can subtract two datetime values and cast the result as a time. You can then format the result however you like.