0

但是,我需要在 mysql 中搜索日期,如果列类型是日期,则它不起作用。我需要更改为文本类型是日期类型的任何方法

这是我的查询

SELECT Count(CaseStatus) as CompletedCase From checkfinale where CaseStatus='2' AND CompanyID='51' AND `CompletedDate` BETWEEN '2012-05-29' AND '2012-06-05'
4

2 回答 2

1

如以下链接所述,尝试铸造您的常量字符串进行比较: http ://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#operator_between

AND `CompletedDate` BETWEEN CAST('2012-05-29' AS DATE) AND CAST('2012-06-05' AS DATE)
于 2012-06-17T06:28:26.730 回答
1

您还可以将日期指定为简单的 YYYYMMDD

BETWEEN 20120529 AND 20120605
于 2012-06-17T07:11:50.240 回答