日期:2014-05-19  浏览次数:20909 次

SQL 输入项无法被转换为有效日期时间值
我在进行SQL表查询的时候.
输入如下语句:
SELECT   *
FROM   SEND
WHERE   SEND_TIME   LIKE   '%2007-6-8% '
结果显示:
"当前"SQL"窗格内容做语法分析时发生下列错误:
输入项无法被转换为有效日期时间值."

请各位路过的高手帮个忙!小弟在线等!

------解决方案--------------------
SELECT *
FROM SEND
WHERE convert(varchar(10),SEND_TIME,120) = '2007-06-08 '

------解决方案--------------------
SELECT *
FROM SEND
WHERE CONVERT(varchar(30),SEND_TIM,102) LIKE '%2007-6-8% '


不过没心要这样

SELECT *
FROM SEND
WHERE CONVERT(varchar(30),SEND_TIM,102) = '2007-06-8 '
------解决方案--------------------
SELECT *
FROM SEND
WHERE SEND_TIME LIKE '%2007-6-8% '
--------------------------------------
改成:
SELECT *
FROM SEND
WHERE convert(varchar(10),SEND_TIME,101) LIKE '%2007-6-8% '

------解决方案--------------------
在end if后加response.write times 或 msgbox(times)看看获得的是什么值
------解决方案--------------------
先帮顶一下,有事,用上面的方法,把sql显示出来,在查询分析器下执行,贴出来让大家分析吧
------解决方案--------------------
把党中那段换成这样试试
应该可以了
sql= "select * from send where Convert(nvarchar,send_yxtime,23) = Convert(nvarchar,Convert(datetime, ' "&times& " '),23) "
elseif request.Form( "action ")= "send_time " then
sql= "select * from send where Convert(nvarchar,send_time,23)= Convert(nvarchar,Convert(datetime, ' "&times& " '),23) "