我试图在两个日期之间获取记录,但是当我运行SQL时出现以下错误:
操作数类型冲突:datetime2与int
不兼容SELECT M.Id, M.MTimeInt, M.Date, CAST(D.Name AS TEXT) as Name
FROM C
JOIN N ON C.N_Id=N.Id
JOIN M ON M.N_Id=N.Id
JOIN MDish ON MDish.M_Id=M.Id
JOIN D ON D.Id=MDish.D_Id
WHERE C.Id=110 AND M.Date BETWEEN 2012-05-28 AND 2012-06-08
SQL看起来是正确的,但我似乎无法弄清楚为什么抱怨,任何想法?
由于
答案 0 :(得分:6)
尝试:
BETWEEN '2012-05-28' AND '2012-06-08'
否则它是2012 minus 05 minus 28
,等于1979
并且是整数而不是日期。