我认为mysql可以计算它,所以我创建了一个名为$sqlDateDiff
的变量。
$servername = "localhost";$username = "root";$password = "";$dbname = "maplibrary";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sqlDateDiff = "SELECT DATEDIFF(BorrowedDate, ReturnedDate)
FROM bookstakenout WHERE BorrowNumberID = $bnid" ;
$result = mysqli_query($conn, $sqlDateDiff);
然后我想使用$result
创建一个嵌套的if
语句。如何将差异存储在变量中以在if
语句中使用。
在bookstakenout
表中,ReturnedDate/BorrowedDate
都是yyyy-mm-dd
块引用
答案 0 :(得分:0)
查询:DATEDIFF(日期部分,开始日期,结束日期)为DIFFDATE