Skip to content

Instantly share code, notes, and snippets.

@leandrogilvalle
Last active April 28, 2016 21:43
Show Gist options
  • Select an option

  • Save leandrogilvalle/1740d1285d1a1413b142ef53772b675d to your computer and use it in GitHub Desktop.

Select an option

Save leandrogilvalle/1740d1285d1a1413b142ef53772b675d to your computer and use it in GitHub Desktop.
PLSQL - Diferença entre duas datas - retorno no formato HH24:mi:ss
SELECT trim(to_char(floor(((date1-date2)*24*60*60)/3600), '00')) || ':' ||
trim(to_char(floor((((date1-date2)*24*60*60) - floor(((date1-date2)*24*60*60)/3600)*3600)/60), '00')) || ':' ||
trim(to_char(round((((date1-date2)*24*60*60) - floor(((date1-date2)*24*60*60)/3600)*3600 -
(floor((((date1-date2)*24*60*60) - floor(((date1-date2)*24*60*60)/3600)*3600)/60)*60) )), '00'))
as time_difference
FROM dates;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment