PL SQL Data Types Oracle PLSQL Tutorial

Finding the Difference between Dates.

SQL>
SQL> create or replace function f_secBetween_nr (i_date1_dt DATE,i_date2_dt DATE)
  2  return NUMBER is
  3      v_ret_nr NUMBER;
  4  begin
  5      v_ret_nr:=i_date1_dt-i_date2_dt;
  6      return v_ret_nr*(24*60*60);
  7  end f_secBetween_nr;
  8  /
Function created.
SQL> select f_secBetween_nr(sysdate, sysdate +1) from dual
  2  /
F_SECBETWEEN_NR(SYSDATE,SYSDATE+1)
----------------------------------
                            -86400