【发布时间】:2012-12-14 09:24:26
【问题描述】:
我有一条 SQL 语句来显示两个日期之间的数据。我几乎明白了,但有一个问题。
如果我输入 March 1,2012 to March 7, 2012.. 它应该显示日期介于两者之间的数据.. 但它也会显示 2012 年 3 月以下的所有日期.. 但每当我输入 2012 年 3 月 10 日到 2012 年 3 月 30 日时,SQL完美运行..任何帮助将不胜感激。谢谢
SELECT
agentname, noofcalls, qualified, booking, resched,
actualbooking, sales, remarks,
concat(month,' ',day,',',year) as 'date'
FROM
tblagents
WHERE
(month between '" & cbosmonth.Text & "' AND '" & cboemonth.Text & "')
AND (day between '" & cbosday.Text & "' AND '" & cboeday.Text & "')
AND (year between '" & cbosyear.Text & "' AND '" & cboeyear.Text & "')"
【问题讨论】:
-
为什么不将日期存储在单个字段中(适合日期算法类型)?
-
这看起来像是即将发生的SQL Injection 攻击。
-
@zerkms 你能教我怎么做吗?
-
@user1841167: msdn.microsoft.com/en-us/library/ms186724.aspx
-
你能用数据库版本和使用的应用程序语言编辑问题吗?
标签: sql sql-server vb.net between