当使用Date 而且 Time值时,必须将字段转换为DateTime而不是Date。
试一试:< / p >
SELECT * FROM `objects`
WHERE (CAST(date_field AS DATETIME)
BETWEEN CAST('2010-09-29 10:15:55' AS DATETIME) AND CAST('2010-01-30 14:15:55' AS DATETIME))
$stmt = $db->query(
"SELECT * FROM table
WHERE (CAST(CURDATE() AS date)
BETWEEN
CAST(table.date_start AS date)
AND
CAST(table.date_end AS date))
LIMIT 1"
);
Case 1: SELECT * FROM table_name WHERE DATE(date_field) BETWEEN '2016-12-01' AND '2016-12-10' // include 2016-12-10
Case 2: SELECT * FROM table_name WHERE (date_field BETWEEN '2016-12-01' AND '2016-12-10') // not include 2016-12-10