上次做到关于用时间的模糊查询的时候,走了好多弯路,最后还是网上以为前辈给了这种方法,在这里表示感谢。
三种方法是:
1.Convert转成String,再用like查询
select * from tabel1 where convert(varchar,date,120) like '2014-03-20%'//里面的date就是里数据表里表示时间那个字段,也就是你现在用到的那个时间字段
2.Between
select * from tabel1 where time between '2014-03-05 00:00:00' and '2014-03-25 23:58:36'
3.datediff()函数
select * from table1 where datediff(day,time,'2014-03-25')=0