postdate字段中的值是‘2007-11-10’格式的。
我是这样写的
CREATE DEFINER = 'root'@'localhost' PROCEDURE `updateQuestionStatus`()
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
UPDATE zd_question set zd_question.active=0 where TO_DAYS(NOW())-TO_DAYS('postdate')>=15;
END;
用java程序执行后没反应,
在mysql命令行下执行:
select TO_DAYS('postdate') from question;
查询结果全为null
恳请诸位指点!
怎样才能实现把15天前的记录的status字段值置为0?
谢谢
3 个解决方案
#1
用DATEDIFF函数
DATEDIFF(now(),postdate)
DATEDIFF(now(),postdate)
#2
谢谢大哥!
#3
TO_DAYS(NOW())-TO_DAYS('postdate')>=15
改成TO_DAYS(NOW())-TO_DAYS(postdate)>=15,
把单引号去掉就可以了
改成TO_DAYS(NOW())-TO_DAYS(postdate)>=15,
把单引号去掉就可以了
#1
用DATEDIFF函数
DATEDIFF(now(),postdate)
DATEDIFF(now(),postdate)
#2
谢谢大哥!
#3
TO_DAYS(NOW())-TO_DAYS('postdate')>=15
改成TO_DAYS(NOW())-TO_DAYS(postdate)>=15,
把单引号去掉就可以了
改成TO_DAYS(NOW())-TO_DAYS(postdate)>=15,
把单引号去掉就可以了