Mark Mark - 2 years ago 85
PHP Question

Check if the current date is between two dates + mysql select query

I have following table :

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

I want to compare todays date in between dateStart and dateEnd.

Following is my query for this :

$db = Zend_Registry::get("db");
$result = $db->fetchAll("SELECT * FROM `table` WHERE active=0 AND {$todaysDate} between dateStart and dateEnd");
return $result;

But its not working.
Any solution.
Thanks in advance.

Answer Source

Try this :: This will solve your problem

SELECT * FROM `table` WHERE active=0 AND CURDATE() between dateStart and dateEnd
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download