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)

v_sdate DATE;
v_edate DATE;
–r_exception     EXCEPTION;

DBMS_OUTPUT.put_line ( ‘Process Start Time: ‘
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)
—  RAISE r_exception;
raise_application_error(-20001,’An error was encountered – Provide correct date’);
–dbms_output.put_line(‘BAD DATE PROVIDED’);
End IF;

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


Author: Abdul H Khan

Trying to be cloudy!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s