读书人

请高手帮忙看下,这个sql语句那里有错?

发布时间: 2012-03-17 19:06:28 作者: rapoo

请高手帮忙看下,这个sql语句那里有错?
Select ExhibitionID,ClassID,IsHtml,HtmlFileUrl,UpdateTime from Cl_exhibition where Passed=1 and Deleted=0 and datediff( 'd ',UpDateTime,GetDate()) <=datediff( 'd ', '2007-06-03 ',GetDate()) and datediff( 'd ',UpDateTime,GetDate())> =datediff( 'd ', '2007-06-13 ',GetDate()) and ChannelID=9 order by UpDateTime desc,ExhibitionID desc


Microsoft OLE DB Provider for SQL Server 错误 '80040e14 '

为 datediff 指定了无效的参数 1。

/Admin/Admin_Create_exhibition.asp,


[解决办法]
去掉“d”引号

Select ExhibitionID,ClassID,IsHtml,HtmlFileUrl,UpdateTime from Cl_exhibition
where Passed=1 and Deleted=0 and
datediff(d,UpDateTime,GetDate()) <=datediff(d, '2007-06-03 ',GetDate())
and
datediff(d,UpDateTime,GetDate())> =datediff(d, '2007-06-13 ',GetDate())
and ChannelID=9
order by UpDateTime desc,ExhibitionID desc


[解决办法]
语法
DATEDIFF ( datepart , startdate , enddate )

参数
datepart

是规定了应在日期的哪一部分计算差额的参数。下表列出了 Microsoft® SQL Server™ 识别的日期部分和缩写。

日期部分 缩写
year yy, yyyy
quarter qq, q
Month mm, m
dayofyear dy, y
Day dd, d
Week wk, ww
Hour hh
minute mi, n
second ss, s
millisecond ms

[解决办法]
datediff( 'd ',UpDateTime,GetDate()) 第一个参数不要单引号

=〉

datediff(d,UpDateTime,GetDate())

读书人网 >ASP

热点推荐