如何使用PHP获取mysql数据库中指定时间段之间的记录?
我的代码就是这个;
$records= "SELECT * FROM contact_us WHERE \'submit_date(date(\"H:i:s\"))\' between \'16:00:00\' and \'08:00:00\'";
答案 0 :(得分:1)
使用http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
中的时间函数SELECT * FROM contact_us WHERE HOUR(submit_date) >= 16 AND HOUR(submit_date)<= 8
答案 1 :(得分:0)
试试这个
SELECT * FROM contact_us WHERE CONVERT(VARCHAR(8),attributename,108) between '16:00:00' and '08:00:00';
答案 2 :(得分:0)
$records= "SELECT * FROM contact_us WHERE submit_date between '2012-11-01' and '2012-11-01'";
并将该列的数据类型设为 datetime
答案 3 :(得分:0)
SELECT * FROM contact_us WHERE
HOUR(submit_date) between 8 and 16;