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

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效