Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 512 Bytes

select_date_equal_to_today.md

File metadata and controls

19 lines (14 loc) · 512 Bytes

MySQL支持查询日期格式类似shell的date +%Y%m%d这样的方法,所以就很容易对比时间:

SELECT users.id, DATE_FORMAT(users.signup_date, '%Y-%m-%d') 
FROM users 
WHERE DATE(signup_date) = CURDATE()

或者

SELECT users.id, DATE_FORMAT(users.signup_date, '%Y-%m-%d') 
FROM users 
WHERE DATE_FORMAT(users.signup_date, '%Y-%m-%d') = CURDATE()

参考