1、事件驱动就会用到获取各种时间,现在的时间,与现在的时间差;
<p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; text-align: justify; background-color: rgb(250, 250, 252);">TIMESTAMPDIFF(interval,datetime_expr1,datetime_expr2)。</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; text-align: justify; background-color: rgb(250, 250, 252);"><span style="white-space: pre;"></span>说明:</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; text-align: justify; background-color: rgb(250, 250, 252);"><span style="white-space: pre;"></span>返回日期或日期时间表达式datetime_expr1 和datetime_expr2the 之间的整数差。其结果的单位由interval 参数给出。</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; text-align: justify; background-color: rgb(250, 250, 252);">每三分钟检查一次数据库中的数据,检查与现在时间相差48小时的内容,将state更改为1;</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; text-align: justify; background-color: rgb(250, 250, 252);">update advices set state='1' where state='0' and TIMESTAMPDIFF(DAY,CREATE_at,now())>2
</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; text-align: justify; background-color: rgb(250, 250, 252);">2、与现在的时间对比:比现在的时间早就将状态更改为1;</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; text-align: justify; background-color: rgb(250, 250, 252);">update drug_info set state='1' where state='0' and drug_end<now();
</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; text-align: justify; background-color: rgb(250, 250, 252);">获取当前时间的函数:</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; text-align: justify; background-color: rgb(250, 250, 252);"><pre id="best-content-476619490" class="best-text mb-10" name="code" style="background-color: rgb(255, 255, 255); white-space: pre-wrap; word-wrap: break-word; font-size: 14px;"> 如果是mysql数据库
select name from 你的表 where leavetime < now()
如果是sql server数据库
select name from 你的表 where leavetime < getdate()
如果是access数据库
select name from 你的表 where leavetime < now()