检查当前日期是否在两个日期之间 + mysql select 查询
我有下表:
id dateStart dateEnd active
1 2012-11-12 2012-12-31 0
2 2012-11-12 2012-12-31 0
我想检查今天的日期是否在 dateStart
和 dateEnd
之间.
I want to check if today's date is in between dateStart
and dateEnd
.
以下是我对此的查询:
$todaysDate="2012-26-11";
$db = Zend_Registry::get("db");
$result = $db->fetchAll("SELECT * FROM `table` WHERE active=0 AND {$todaysDate} between dateStart and dateEnd");
return $result;
但到目前为止它不起作用,因为它返回零行.
But so far it's not working as it returns zero rows.
推荐答案
试试这个 :: 这将解决你的问题
Try this :: This will solve your problem
SELECT * FROM `table` WHERE active=0 AND CURDATE() between dateStart and dateEnd
相关文章