SQL 这个小于日期查询有什么问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6584666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Whats wrong with this less-than date query?
提问by Chucky
sqlite> SELECT * FROM RawResponseTimes WHERE CreationTime <= 2011-06-14 17:17:23;
Error: near ":17": syntax error
Everything appears to be fine but it isn't happy with the hour 17, what gives?
一切似乎都很好,但它对 17 小时不满意,怎么办?
Using SQLite.
使用 SQLite。
回答by Neil Knight
Looks like you are missing '
s from your date.
看起来'
您的约会对象缺少s。
SELECT * FROM RawResponseTimes WHERE CreationTime <= '2011-06-14 17:17:23';
SELECT * FROM RawResponseTimes WHERE CreationTime <= '2011-06-14 17:17:23';
回答by Ovais Khatri
Keep data value in single quotes...
将数据值保留在单引号中...
sqlite> SELECT * FROM RawResponseTimes WHERE CreationTime <= '2011-06-14 17:17:23';
sqlite> SELECT * FROM RawResponseTimes WHERE CreationTime <= '2011-06-14 17:17:23';
回答by RFE Petr
SELECT * FROM RawResponseTimes WHERE CreationTime <= CONVERT(DATETIME, '2011-06-14 17:17:23');