[英]Operand type clash: datetime2 is incompatible with int (Between)
I am trying to get records inbetween two dates, however when I run the SQL I get the following error: 我试图获取两个日期之间的记录,但是当我运行SQL时,出现以下错误:
Operand type clash: datetime2 is incompatible with int 操作数类型冲突: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
The SQL looks correct, but I can't seem to figure out why it is complaining, any idea? SQL看起来正确,但是我似乎无法弄清楚为什么会抱怨,有什么想法吗?
Thanks 谢谢
Try: 尝试:
BETWEEN '2012-05-28' AND '2012-06-08'
Otherwise it's 2012 minus 05 minus 28
, which equals 1979
and is an integer and not a date. 否则为
2012 minus 05 minus 28
,等于1979
,是整数而不是日期。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.