Skip navigation links

MySQL Forums :: Cluster :: Exclude weekends between two dates


Advanced Search

Exclude weekends between two dates
Posted by: aaaa bbb ()
Date: November 12, 2012 05:40AM

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



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;

Options: ReplyQuote


Subject Views Written By Posted
Exclude weekends between two dates 1089 aaaa bbb 11/12/2012 05:40AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.