SELECT c.comment, left(c.time,13)time FROM customercomment c
where c.code='A0052' and c.time >= cast('2008-06-18 00' as datetime)
and c.time<=cast('2008-06-18 21' as datetime);查询结果是 :
'fffffff', '2008-06-18 19'SELECT  c.comment, left(c.time,13)time FROM customercomment c
where c.code='A0052' and time like '%2008-06-18%';查询结果是 :
'fffffff ', '2008-06-18 19'
'eeeeeeeee', '2008-06-18 21'
为什么第一条sql语句21点的数据没有查到呢,谢谢大家

解决方案 »

  1.   

    try:
    SELECT c.comment, left(c.time,13)time FROM customercomment c where c.code='A0052' and c.time >= cast('2008-06-18 00' as datetime) and c.time<=cast('2008-06-18 20:59:59' as datetime); 
      

  2.   

    c.time<cast('2008-06-18 22'
    试试
      

  3.   

    try:
    SELECT c.comment, left(c.time,13)time FROM customercomment c where c.code='A0052' and c.time >= cast('2008-06-18 00' as datetime) and c.time <=cast('2008-06-18 21:59:59' as datetime);
      

  4.   

    检查
    'eeeeeeeee', '2008-06-18 21'这条记录的时间,一定>21:00:00
      

  5.   

    你的条件是c.time<=21点
    21点01秒都是不满足条件的
    所以要改为<22