比较存储在SQL中的varchar中的日期

时间:2019-04-16 11:48:41

标签: sql sql-server

我正在使用我的日期(字符串)与数据库表列Date(varchar)进行比较。它正在工作,但仅比较日期忽略了月份和年份,如。

SELECT * from Report
SELECT * from Report WHERE Date BETWEEN '05-03-2019' AND '07-03-2019'
SELECT * FROM Report WHERE CAST(Date as DATE) BETWEEN CAST('05-02-2019' 
AS DATE) AND CAST('07-02-2019' AS DATE);

0 个答案:

没有答案