这里用的是mybatis
1、时间类型为datetime或date
<if test="activityStartAt!=null"><![CDATA[ and DATE_FORMAT(gp.activity_start_at, '%Y-%m-%d')>= DATE_FORMAT(#{activityStartAt}, '%Y-%m-%d') ]]></if><if test="activityEndAt!=null"><![CDATA[ and DATE_FORMAT(gp.activity_start_at, '%Y-%m-%d') <= DATE_FORMAT(#{activityEndAt}, '%Y-%m-%d') ]]></if>
2、时间类型为varchar
<if test="activityStartAt!= '' ">ANDgp.activity_start_at>=#{activityStartAt}</if><if test="activityEndAt!= '' ">ANDtm.activity_start_at<=#{activityEndAt}</if>