0
 DELIMITER //
CREATE  FUNCTION BusinessDays(d1 DATE,d2 DATE)
RETURNS INT
READS SQL DATA DETERMINISTIC
BEGIN
   DECLARE out_date DATE;
   DECLARE fromdate DATE;
   DECLARE todtae DATE;
   DECLARE minus INT;
   DECLARE result INT;
   SET minus = 0;
   SET result = DATEDIFF(todate , fromdate);
   WHILE (fromdate <= todate) DO
     IF (fromdate = 1 OR fromdate = 7)  THEN
       SET minus = (minus)+1;
     END IF;
     SET fromdate = fromdate + INTERVAL 1 DAY;
   END WHILE;
   RETURN result - minus;
END;
END //
DELIMITER ;

Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 20

4

0 回答 0