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点的数据没有查到呢,谢谢大家
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);
试试
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);
'eeeeeeeee', '2008-06-18 21'这条记录的时间,一定>21:00:00
21点01秒都是不满足条件的
所以要改为<22