Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare date

Status
Not open for further replies.

qqq

Programmer
Mar 26, 2001
8
AU
Hi,
My question is : how to compare some date with sysdate and if the difference more than 10 days, delete those records.
I've create the trigger and following script supposed to do this but it does not.

if (sysdate - :eek:ld.trans_date_time)<10 then
RAISE_APPLICATION_ERROR(-20000,'Cannot Delete a Transaction');

It aloows delete all records, probably that all records date is dd.mm.1995.
any ideas will be appresiated.
 
Compare the date dates using some format masks.
ie to_char(sysdate) - to_char:)old.trans_date_time)
 
Use MONTHS_BETWEEN.

eg
select months_between(date1,date2)
into diff
from dual;

If mod(diff) < 10/31 /* 31 days in a standard month */
then /* less than 10 days */
RAISE_APPLICATION_ERROR(-20000,'Cannot Delete a Transaction');

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top