SQL語句實現查詢一段時間內的數據中要注意的細節問題
細節問題很重要,不注意數據一直對不上例如:
timeSql=” and corder.end_time >= ‘”+startTime+” 00:00:00’ and corder.end_time <= ‘”+endTime;
上面這句是錯誤的,所查的數據沒有最後一天的
timeSql=” and corder.end_time >= ‘”+startTime+” 00:00:00’ and corder.end_time <= ‘”+endTime+” 23:59:59’ “;
此句是正確的,查詢到最後一天24點前。