duanjieyi6582 2015-07-31 13:49
浏览 32
已采纳

两个日期之间的PHP查询?

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.

  • 写回答

1条回答 默认 最新

  • dongyi1524 2015-07-31 14:15
    关注

    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 . "'";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?