我有一个查询需求,需要在两个日期之间选择所有记录,mysql表格的格式是datetime。
我尝试了以下代码,但没有成功。
我尝试了以下代码,但没有成功。
select * from cdr
WHERE calldate BETWEEN '2012-12-01' AND '2012-12-03';
select * from cdr
WHERE calldate BETWEEN '2012-12-01' AND '2012-12-03';
试一试这个:
select * from cdr
WHERE DATE(calldate) BETWEEN '20121201' AND '20121203';
SELECT * FROM cdr WHERE calldate BETWEEN str_to_date('2012-12-01','%Y-%m-%d') AND str_to_date('2012-12-03','%Y-%m-%d');
str_to_date('2017-10-20 14:00:00', '%Y-%m-%d %H:%i:%s')
- virtualLast...
where DATE(calldate) < '20121201' AND DATE(calldate) >= '20121203' OR DATE(calldate) = '20121205'
这只是一个简单的例子。