sql模糊检索
时间模糊检索
select * from ShovelRecord where Convert(varchar,LoadTime,120) like '%data%';
用于查询数据库中特定时间段的数据,如2020-01-01可以直接在2020-01中开始模糊查询,获取2020-01的所有匹配数据
其中的Convert(varchar,LoadTime,120)作用是将LoadTime转化为120型的字符串数据(yyyy-mm-dd hh:mm:ss),在将其与data比较
参考
SqlServer数据库中,日期的模糊查询
(convert(varchar(10),getdate(),120)) 这句话是什么意思?
sql 时间范围检索
select * from VehicleStateRecord where CreateTime between '2020-07-31 20:48:00'and '2020-07-31 20:49:04'
用于检索CreateTime字段在指定范围值的数据,在窗体开发中配和dateTimePicker效果极佳
参考SQL时间范围语句(包含日期段和时间段)