1.查询昨日数据
SELECT *
FROM test
WHERE DATEDIFF(DATE_FORMAT(NOW(),'%Y%m%d'),DATE_FORMAT(created_time,'%Y%m%d')) = 1
2.查询上月数据
SELECT *
FROM test
WHERE PERIOD_DIFF(DATE_FORMAT( NOW(), '%Y%m' ),DATE_FORMAT( create_time, '%Y%m' )) = 1
标签:m%,FORMAT,Mysql,Y%,查询,上个月,DATE,WHERE
From: https://www.cnblogs.com/eaglex3/p/16941283.html