2016-08-30 64 views
-1

嘗試將一天添加到此,所以當查詢傳遞時它將添加,所以如果用戶選擇06-30-2017,它會說< 06-31-2017,現在它只能說< 06-30-2017,所以它不包括那個日期。如何新增一天

這裏是做

$query .= " AND scc.date_completed >= '" . $inputs['submitted_customer_credit.date_completed'][0] . " 00:00:00' AND scc.date_completed <= '" . $inputs['submitted_customer_credit.date_completed'][1] . " 23:59:59' "; 
+1

也許<=,而不是<? – user3486184

+0

你可以像這樣通過PHP添加1天:http://stackoverflow.com/questions/1394791/adding-one-day-to-a-date – cmnardi

回答

0

我不知道你正在使用什麼數據庫管理系統,但你可以嘗試DATEADD()代碼。它會沿着這個線路...

WHERE column < 06-30-2017 <- results what you are getting 
WHERE column < DATEADD(dd, 1, 06-30-2016) 

所以你可能是這樣的......

if ($inputs['submitted_customer_credit.date_completed'][1] != '') { 
      $query .= " AND scc.date_completed < DATEADD(dd, 1, '" . $inputs['submitted_customer_credit.date_completed'][1] . "') "; 
     }