有关于时间的模糊查询

来源:互联网 发布:expressVPN软件 编辑:程序博客网 时间:2024/06/06 14:09
有关于时间的模糊查询有以下三种方法:1.Convert转成String,在用Like查询。select * from table1   where convert(varchar,date,120) like   '2006-04-01%'  2.Betweenselect * from table1 where time between '2006-4-1 0:00:00' and '2006-4-1 24:59:59'";3 datediff()函数select * from table1   where datediff(day,time,'2006-4-1')=0 第一种方法应该适用与任何数据类型;第二种方法适用String外的类型;第三种方法则是为date类型定制的比较实用快捷的方法。
原创粉丝点击