Answers:
SELECT * FROM users WHERE created >= CURDATE();
但是我想你是说 created < today
SELECT * FROM myTable WHERE DATE(myDate) = DATE(NOW())
了解更多:http : //www.tomjepson.co.uk/tutorials/36/mysql-select-where-date-today.html
SELECT * FROM users WHERE created >= NOW();
如果列是日期时间类型。
如果该列具有索引并且对该列应用了函数,则索引将不起作用,并且会进行全表扫描,从而导致查询速度非常慢。
要使用索引并将日期时间与今天/当前日期进行比较,可以使用以下内容。
OP解决方案:
select * from users
where created > CONCAT(CURDATE(), ' 23:59:59')
样本以获取今天的数据:
select * from users
where
created >= CONCAT(CURDATE(), ' 00:00:00') AND
created <= CONCAT(CURDATE(), ' 23:59:59')
或简称为BETWEEN
select * from users
where created BETWEEN
CONCAT(CURDATE(), ' 00:00:00') AND CONCAT(CURDATE(), ' 23:59:59')
SELECT * FROM table_name WHERE CONCAT( SUBSTRING(json_date, 11, 4 ) , '-', SUBSTRING( json_date, 7, 2 ) , '-', SUBSTRING(json_date, 3, 2 ) ) >= NOW();
json_date [“ 05/11/2011”]
您可以返回所有行,然后在if语句内使用php datediff函数,尽管这样做会给服务器带来额外的负担。
if(dateDiff(date("Y/m/d"), $row['date']) <=0 ){
}else{
echo " info here";
}
CURDATE()
只返回日期而不返回时间