在 MYSQL 中使用 BETWEEN 的日期

Date using BETWEEN in MYSQL

我想显示使用两个不同日期的记录。我尝试使用 Between

select * from billing where select_client = '2' and order_date BETWEEN '01/06/2018' and '30/06/2018' order by id ASC 

它returnsJULY月记也。我尝试使用 >= 和 <=。该查询也 returns 相同的记录。

select * from billing where select_client = '2' and order_date >= '01/06/2018' and order_date <= '30/06/2018' order by id ASC 

请帮我只获取两个日期之间的记录。提前致谢

日期格式错误。如果 order_date 是 mysql DATE 那么格式应该是 2018-06-01

您必须将字符串转换为日期才能进行比较:

select * from billing where select_client = '2' and STR_TO_DATE(order_date, '%d/%m/%Y') BETWEEN STR_TO_DATE('01/06/2018','%d/%m/%Y') and STR_TO_DATE('30/06/2018','%d/%m/%Y') order by id ASC