Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have the 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 check if today's date is in between dateStart and dateEnd.

The following is my query for this :

$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.

like image 452
J.K.A. Avatar asked Nov 26 '12 10:11

J.K.A.


1 Answers

Try this :: This will solve your problem

SELECT * FROM `table` WHERE active=0 AND CURDATE() between dateStart and dateEnd
like image 170
Sashi Kant Avatar answered Oct 02 '22 11:10

Sashi Kant