这样写:
where DateCol >= '2001-01-01 00:00:00' and DateCol < '2001-01-02 00:00:00'

解决方案 »

  1.   

    也可以这样:
    ...where convert(char(8), DateCol, 112) = '20010101'
      

  2.   

    convert(char(8), DateCol, 112) = '20010101' 
    我用过好像不行 我的是 mssql 7.0 家的是mssql2000中文版 好像对于datetime 的处理不一样,说明书上建议用 like %,用like 会自动转换到字符串,有谁知到datetime 用like 会转换成何样?
      

  3.   

    DateCol >= '2001-01-01 00:00:00' and DateCol < '2001-01-02 00:00:00' 
    实在不行只好用他了,convert(char(8), DateCol, 112) = '20010101',会使索引性能下降,是吗? 
      

  4.   

    不应该呀,我刚试过:convert(char(8), DateCol, 112) = '20010101' ,怎么不行,报什么错?是的,它“会使索引性能下降”
      

  5.   

    convert(char(8), DateCol, 112) = '20010101'  我这无纪录返回
    select * from aa where convert(char(8), aa, 112) = '20010101';aa = datetime '2001-01-01 09:09:09'
      

  6.   

    你这样试一下:
    select convert(char(8), aa, 112) from table看返回了什么?
      

  7.   

    你看这个返回什么:
    select convert(char(8), getdate(), 112)
      

  8.   

    我看了下帮助,112应该返回的是yyyymmdd, 12返回的是yymmdd
      

  9.   

    to:NetColorWolf(NCW) 
    帮忙看看这个http://www.csdn.net/expert/topic/325/325311.shtm
    我的表是dbf