我在查询分析器中输入下面的查询语句查询datetime型的数据,连语法解析都通不过:
select *
from table_1
where supply_time=2006-01-01 00:00:00.000;
但是把时间去掉以后就能解析成功,但却找不到该记录(表中存在该记录:2006-01-01 00:00:00.000):
select *from table_1where supply_time=2006-01-01 ;恳求大下们帮帮忙。

解决方案 »

  1.   

    你表里的数据类型是不是定义成字符型了?
    用select *
    from table_1
    where supply_time='2006-01-01 00:00:00.000'
    试看看
      

  2.   

    select *
    from table_1
    where supply_time='2006-01-01 00:00:00.000';
    不行的话就
    select * from table_1 where supply_time=cast('2006-01-01 00:00:00.000' as datetime)
    再不行就将就一点
    select * from table_1 where convert(varchar(10),supply_time,120)='2006-01-01'
      

  3.   

    select *
    from table_1
    where supply_time>='2006-01-01' and supply_time<'2006-01-02'--查询2006-01-01这一天的数据