PL/SQL Procedure to compare dates

Hello All,

I haven’t updated my blog in a while, so here is what i have been working on:

I was asked to put together pl/sql procedure which can compare the date and use the output to do something:

This Procedure takes two date input from user and compare if date is less then 1 day old(value can be adjusted according to business requirement).

CREATE OR REPLACE PROCEDURE TEMP1(sdate in varchar2, edate in varchar2)
IS

v_sdate DATE;
v_edate DATE;
–r_exception     EXCEPTION;

BEGIN
DBMS_OUTPUT.put_line ( ‘Process Start Time: ‘
||TO_CHAR (SYSDATE, ‘MM/DD/YYYY HH24:MI:SS’)
);
BEGIN
select to_date(sdate, ‘YYYY-MM-DD:HH24:MI’)
into v_sdate
from dual;

select to_date(edate, ‘YYYY-MM-DD:HH24:MI’)
into v_edate
from dual;
if (v_edate – v_sdate >2 )
–IF (SYSDATE – v_sdate > 60)
THEN
—  RAISE r_exception;
raise_application_error(-20001,’An error was encountered – Provide correct date’);
–dbms_output.put_line(‘BAD DATE PROVIDED’);
–RASIE_APPLICATION_ERROR(-2100, ‘DATE issue’);
End IF;

DBMS_OUTPUT.put_line (‘START DATE: ‘|| v_sdate);
DBMS_OUTPUT.put_line (v_edate);
end;
END;
/