日期:2014-05-18  浏览次数:20487 次

求助一条SQL语句
select   count(*)   as   countno   from   tgrht   where   (Fxb=1)     and   (TZZ_ID=1)   and   (fhtzzrq < '2007-09-12 ')   为什么出错,报类型不匹配错误。应该是日期那里,但是用to_date却说没有这个函数,有没别的办法?

Fxb和TZZ_ID   分别是数值型   fhtzzrq为日期型字段

高手帮帮忙

------解决方案--------------------
select count(*) as countno from tgrht where (Fxb=1) and (TZZ_ID=1) and (fhtzzrq < '2007-09-12 ') 为什么出错,报类型不匹配错误。应该是日期那里,但是用to_date却说没有这个函数,有没别的办法?

Fxb和TZZ_ID 分别是数值型 fhtzzrq为日期型字段

高手帮帮忙
----------------
时间可以这样比较呀!
另外,SQL里用cast( '2007-09-12 ' as datetime) 或convert(datetime, '2007-09-12 ',120)可以转化时间
------解决方案--------------------
時間可以這樣比較
SELECT * FROM sysobjects WHERE crdate < '2007/10/1 '
/*(2680 row(s) affected)*/
------解决方案--------------------
select count(*) as countno from tgrht where (Fxb=1) and (TZZ_ID=1)
and (fhtzzrq < '2007-09-12 ')
日期应该没错
是前面两个错了吧

试试
select count(*) as countno from tgrht where (Fxb=1) and (TZZ_ID=1)

select count(*) as countno from tgrht where (fhtzzrq < '2007-09-12 ')
就知道了
------解决方案--------------------
这么怪的,什么数据库