【发布时间】:2020-05-05 13:54:27
【问题描述】:
我正在编写我的第一个 mysql 程序。我有一个 date 变量和 2 个整数变量。我将两个整数变量相乘,然后将结果整数添加到date 变量中。
例如:
pint=6;
noftimes=3
sdate=2020-05-05
totDays=pint*noftimes
edate=2020-05-05+totDays
我可以添加多个pint*noftimes,但不能添加sdate+totDays。而如果我添加sdate+10,那么我将得到一个正确的增量日期值。以下是我的程序:
DELIMITER $$
CREATE DEFINER=`pattu`@`localhost` PROCEDURE `getFieldWorkDates`(IN `p_id` INT, OUT `totDays` INT, OUT `edate` DATE)
BEGIN
DECLARE noftimes int;
DECLARE pint int;
DECLARE sdate DATE;
DECLARE tdays int;
SELECT startDate into sdate from projects where idprojects=p_id;
SELECT projectDuration into noftimes from projects where idprojects=p_id;
SELECT recFreq into pint from projects where idprojects=p_id;
SET totDays=pint*noftimes;
SET edate = sdate+(pint*noftimes);
END$$
DELIMITER ;
执行此操作时,我收到消息,您的查询已成功执行。 0 行受影响
【问题讨论】:
-
@Akina 谢谢……它成功了。我可以接受这个作为答案。