检查当前日期是否在两个日期之间+ MySQL Select查询

问题描述:

我有下表:

id     dateStart     dateEnd      active
1      2012-11-12    2012-12-31   0
2      2012-11-12    2012-12-31   0

我想检查今天的日期是否在dateStartdateEnd之间.

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