简体   繁体   English

两个日期之间的PHP查询?

[英]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 .所以,我有一个日期为28/01/2014的测试,下一个测试将于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.我希望查询查找Next Test Due已过期的过期Next Test Due

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 . "'";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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