SQL语句实现日期时间模糊查询

在SQL因为日期时间的格式缘由,咱们不能直接使用LIKE关键进行模糊查询,除了between in外,咱们还可使用数据库的各类函数先将时间转换成字符串,再使用LIKE,例以下面MySQL语句:数据库

SELECT 
    user.userid,
	user.name,
	user.contact,
	user.city,
	user.source,
	user.status,
	user.note,
	date_format(user.createDate,'%Y-%m-%d %H:%i:%s') createDat
FROM livi_potential_user user 
WHERE 
    date_format(user.createDate,'%Y-%m-%d %H:%i:%s') LIKE CONCAT('%','2017-08','%')
相关文章
相关标签/搜索