SELECT * FROM `attendancealert` WHERE DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(`AlertTime`)),‘%Y-%m-%d‘) = DATE_FORMAT(NOW(), ‘%Y-%m-%d‘) //先将日期格式转成时间戳 然后时间戳转成Y-m-d的时间格式然后 和今天的Y-m-d的时间进行对比 AND DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(`AlertTime`)),‘%h:%i‘) NOT BETWEEN ‘09:00‘ AND ‘10:30‘ //不在这个时间段 ORDER BY `AlertTime` DESC
//我直接把时间转成时间类型不就可以了????
SELECT * FROM `attendancealert` WHERE DATE_FORMAT((`AlertTime`),‘%Y-%m-%d‘)= DATE_FORMAT(NOW(), ‘%Y-%m-%d‘) AND DATE_FORMAT((`AlertTime`),‘%h:%i‘) NOT BETWEEN ‘09:00‘ AND ‘10:30‘ ORDER BY AlertTime ASC
原文地址:https://www.cnblogs.com/wlphp/p/10195682.html
时间: 2024-12-13 06:34:00