查询当前年份新增数据
select * from test where YEAR(create_time) = YEAR(NOW())
查询当去年份新增数据
<if test="param.lastYearStatus != null "> and YEAR(create_time) = YEAR(NOW())-1 </if> <if test="param.seasonStatus != null"> and QUARTER(create_time) = QUARTER(NOW()) AND YEAR (create_time) = YEAR (NOW()) </if> <if test="param.lastSeasonStatus != null"> and QUARTER(create_time) = QUARTER(DATE_SUB(now(),interval 1 QUARTER)) </if> <if test="param.monthStatus != null"> and DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' ) </if> <if test="param.lastMonthStatus != null"> and DATE_FORMAT(create_time,'%Y%m') = DATE_FORMAT(DATE_SUB(curdate(), interval 1 MONTH),'%Y%m') </if>
标签:FORMAT,YEAR,create,time,当前,上个月,DATE,Mysql,QUARTER From: https://www.cnblogs.com/wj123bk/p/16627358.html