【发布时间】:2019-01-06 08:40:14
【问题描述】:
我想使用两个不同的日期显示记录。我尝试使用Between
select * from billing where select_client = '2' and order_date BETWEEN '01/06/2018' and '30/06/2018' order by id ASC
它还返回 7 月的记录。我尝试使用 >= 和
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列的数据类型是什么? -
order_date 数据类型为 varchar。 order_date 的值以这种“07/06/2018”格式存储。如果我将数据类型更改为日期。该字段中的所有记录都将更改为“0000:00:00”。请建议我解决这个问题,因为客户已经以 varchar 数据类型 order_date 格式存储了账单
-
不要将日期存储为 varchar。将其存储为日期类型。要将其与日期进行比较,您必须将其转换为日期
-
如果我将数据类型更改为日期。该字段中的所有记录都将更改为“0000:00:00”。请建议我解决这个问题,因为客户已经以 varchar 数据类型 order_date 格式存储了账单
-
从下面提供的答案中,您应该能够弄清楚如何修复日期,然后是数据类型,这将导致无限更好的解决方案