简体   繁体   中英

PHP query between two dates?

I am trying to set a table up to display out of date tests. So, I have a test that is dated 28/01/2014 and the next test is due on 28/01/2015 . As of today's date, this is out of date.

My query looks like the following:

$expiry = date("Y-m-d");
$queryout = "SELECT appliances.*, tests.* FROM (appliances LEFT JOIN tests  
             ON appliances.ID = tests.Appliance) WHERE Cli_ID = '$useractiveid' 
             AND `Next Test Due` BETWEEN `Date Tested` AND  '" . $expiry . "'";

I want the query to find tests that are out of date where the Next Test Due is out of date.

Here is my answer based on my comments:

$expiry = date("Y-m-d");
$queryout = "SELECT appliances.*, tests.* FROM (appliances LEFT JOIN tests  
             ON appliances.ID = tests.Appliance) WHERE Cli_ID = '$useractiveid' 
             AND where Next Test Due < '" . $expiry . "'";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM