mysql 时间间隔计算
业务需求说明
早8:30点执行该sql,写入定时脚本
【在稳定前,需要手动复检】
INSERT INTO
test_error
(
url,
no_open_times,
no_ad_times,
ok_times,
remarks,
script_need_run_times,
create_time,
update_time
)
SELECT
url,
no_open_times,
no_ad_times,
ok_times,
remarks,
script_need_run_times,
create_time,
update_time
FROM test_error_temp
WHERE no_open_times+no_ad_times+ok_times>=36
AND
FROM_UNIXTIME(create_time,'%Y-%m-%d ')='2017-12-25'
;
SELECT NOW(),CURDATE(),CURTIME(),DATE_SUB(CURDATE(),INTERVAL 1 DAY), DATE_SUB(CURDATE(),INTERVAL -1 MONTH),DATE_ADD(CURDATE(),INTERVAL -1 WEEK);
减负加正
NOW() CURDATE() CURTIME() DATE_SUB(CURDATE(),INTERVAL 1 DAY) DATE_SUB(CURDATE(),INTERVAL -1 MONTH) DATE_ADD(CURDATE(),INTERVAL -1 WEEK)
2017-12-26 09:32:45 2017-12-26 09:32:45 2017-12-25 2018-01-26 2017-12-19
http://www.cnblogs.com/zmengj/p/5725943.html