RE: [PHP-DB] How to check that today's date is within a given range

From: Date: Wed, 05 Feb 2003 00:49:02 +0000
Subject: RE: [PHP-DB] How to check that today's date is within a given range
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-25441@lists.php.net to get a copy of this message
> I have a start_date and a finish_date stored in a mysql db. > > I want to check that today's date falls between these 2 dates. > > Can I set up the 3 dates so that a simple subtraction can be done? eg > > if (($today - $start > 0) && ($finish - $today >0)) { > ...within range... > } else { > ...out of range... > } > > I can't seem to find date functions that are of any use for this. I could have sworn I already answered this today... SELECT ... FROM table WHERE CURDATE() BETWEEN start AND end Where 'start' and 'end' are your columns... It's slightly faster to use CURDATE() > start AND CURDATE < end, but I find BETWEEN easier to read... ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.db (#25441) next »