有一个带有colunm的表来存储日期时间(格式:2014-5-5 9:21 pm)。我正在使用PDO在60天内从此表中获取数据,以计算datetime colunm值。我的查询没有回应。有人可以告诉我出了什么问题吗?
foreach ($myCon->query("SELECT * FROM students_tbl LEFT OUTER JOIN fees_tbl ON students_tbl.username = fees_tbl.studentname WHERE exec_datetime BETWEEN DATE_SUB(DATE_FORMAT(students_tbl.datetime, '%Y-%m-%d %l:%i%p'),INTERVAL '60' DAY)") as $results){
echo $results['grade'];
}
答案 0 :(得分:1)
正确的BETWEEN语法:
somedate BETWEEN date1 and date2
你有什么:
somedate BETWEEN date1