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!

How can I subtract on day in a trigger?

Status
Not open for further replies.

ishelpdesk

Technical User
Mar 16, 2001
9
GB
I would like to subtract on day in a trigger.

How do I do this? I have tried using -1 but it does not like this.

Regards

Grant
 
Hi,

this depends on your DBMS :

in DB2 you would specify like "current date - 1 day" for one day,
or "current date - 1 month" for a month,
or "current date - 1 month - 1 day" for a month and a day .

Other systems offer funcitons like TODAY, CURDATE, or so .

Hope this helps, if not, please state the DBMS you are using.

Regards,
milan432
 
SET SCHEMA MTRC!
DROP TRIGGER T_RESTPBYUNIT_IA1!
CREATE TRIGGER T_RESTPBYUNIT_IA1
AFTER INSERT ON RESERVETYPEBYUNIT
REFERENCING NEW AS new
FOR EACH ROW
MODE DB2SQL

BEGIN ATOMIC

DECLARE ld_adjusteddate DATE;

SET ld_adjusteddate = (new.startdate -1);

UPDATE RESERVETYPEBYUNIT
SET enddate = ld_adjusteddate
WHERE enddate is null AND id <> new.id;

END!

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top