一开始我向一个表里插入数据时,
用getdate()函数给一个列(registertime)赋了一个datetime类型的数据,
它在数据库里是这样显示的:2010-4-11 22:17:41(举个例子)。现在我想查询列(registertime)的日期,不包括时间,就是查询一天的所有记录。请问这样的select和update各怎样写?
我也写了一个查询语句,但是不能用
select * from table where left(registertime,5) like '(select left(registertime,5) from waybill_d)%'

解决方案 »

  1.   

    select * from table where  DATEDIFF(MONTH, ProduceTime, '" + 条件 + "')
    用这个
      

  2.   

    比如查询当天的:
    select * from table where datediff(dd,registertime,getdate())=0
      

  3.   

    select * from table where DATEDIFF(MONTH, registertime, '" + 条件 + "')
      

  4.   

    select * from table where CONVERT(varchar(100), registertime, 23) = "2010-4-11"
      

  5.   

    datediff(),不知道可以上谷歌摆渡一下.
      

  6.   

    select * from table where registertime>(substring(registertime,1,10)+' 00:00:00') and registertime<(substring(registertime,1,10)+' 23:59:59')
      

  7.   

    SELECT *
    FROM table
    where (DATEPART(year, getdate()) = '2010') and  (DATEPART(month, getdate()) = '3') and (DATEPART(day, getdate()) = '12')