MySQL 查询昨天中午12点到今天中午12点的数据
这个字段是格式化的时间字段
SELECT * FROM gs_custom_yuanxiaozixun WHERE tbdate >= CONCAT(DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 DAY),'%Y-%m-%d'),' 12:00:00') AND tbdate <= CONCAT(DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 0 DAY),'%Y-%m-%d'),' 12:00:00')
这个字段是时间戳
select count(*) as total from {$dbtbpre}enewsmember WHERE FROM_UNIXTIME(registertime) >= CONCAT(DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 DAY),'%Y-%m-%d'),' 24:00:00') AND FROM_UNIXTIME(registertime) <= CONCAT(DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 0 DAY),'%Y-%m-%d'),' 24:00:00')