Hi all I'm trying to write a Procedure to subtract days from a data but Ignoring weekends.
This is what I have so far but I have a Syntax error Unexpected END, Expecting ;
I have put a ; after the last END but still get the same error.
DELIMITER $$
CREATE PROCEDURE `production`.`new_procedure` (in fDate Date, fVal int)
BEGIN
Declare x int default 1;
Declare NewDate Date;
WHILE x <= fVal DO
set NewDate=Date_SUB(fDate,interval x Day);
SELECT
CASE DAYNAME(NewDate)
WHEN `Saturday` THEN fVal=fVal+1
WHEN `Sunday` THEN fVal=fVal+1
Else x=x+1
END
End
END$$