Good morning, this is my Trigger, i juste want to exclude all the saturdays/sundays between these two dates >> x = cf_802 and cf_860
ex1 : if delay(cf_865) < 3days
cf_802 = 16/11/2012 ( Next Friday )
cf_865 = 2days ( cf_865 )
Our will have this date :
cf_860 = 21/11/2012
ex2 : if Delay(cf_865 between 8day and 12 day )
cf_802 = 16/11/2012
cf_865 = 12days
output without weekends : 17 et 18 Non + 24 et 25 Non + 1 et 2 Non
will be >> 04/12/2012
ex1 : if delay(cf_865) < 3days
cf_802 = 16/11/2012 ( Next Friday )
cf_865 = 2days ( cf_865 )
Our will have this date :
cf_860 = 21/11/2012
ex2 : if Delay(cf_865 between 8day and 12 day )
cf_802 = 16/11/2012
cf_865 = 12days
output without weekends : 17 et 18 Non + 24 et 25 Non + 1 et 2 Non
will be >> 04/12/2012
Code:
CREATE TRIGGER Before_Update_TriggerAnalyse BEFORE Update ON vtiger_analysecf
FOR EACH ROW
begin
DECLARE x date;
SET x=( select cf_802 from vtiger_echantilloncf where echantillonid in (select echantillonid from vtiger_echantillon where code in (select cf_925 from vtiger_analysecf where cf_925 = NEW.cf_925)));
if NEW.cf_865 < 3 THEN SET NEW.cf_860=TIMESTAMPADD(DAY,1+NEW.cf_865,x);
ELSEIF NEW.cf_865 between '3' AND '8' THEN SET NEW.cf_860=TIMESTAMPADD(DAY,-1+NEW.cf_865,x);
ELSEIF NEW.cf_865 between '8' AND '12' THEN SET NEW.cf_860=TIMESTAMPADD(DAY,-2+NEW.cf_865,x);
ELSE SET NEW.cf_860=TIMESTAMPADD(DAY,-5+NEW.cf_865,x);
END IF;
END;