我已经编写了mysql存储函数来计算工作日,但是当我运行此代码时它显示错误

时间:2012-06-18 10:58:20

标签: mysql function

 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 ;
  

错误代码:1064您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在第20行的“END”附近使用正确的语法

0 个答案:

没有答案