title: Oracle SQL time difference in HH:MM:SS
body: <p>I am trying to get time difference in Oracle database. The time difference for all the rows is okay except for one row. Here is the query</p>
  
  <pre><code>SELECT MAX(REGEXP_SUBSTR (CAST(TO_DATE(call_end, 'YYYY/MM/DD HH24:MI:SS') AS TIMESTAMP) - CAST(TO_DATE(call_start, 'YYYY/MM/DD HH24:MI:SS') AS TIMESTAMP), '\d{2}:\d{2}:\d{2}')) AS call_time
  FROM calls
  </code></pre>
  
  <p>The time difference occurs with the following row:</p>
  
  <p>call_end: '2020-02-20 13:00:20'<br>
  call_start: '2020-02-20 12:56:03'</p>
  
  <p>The returned result is '11:55:43' which is wrong. As the correct answer should be '00:04:17'</p>