社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
类似于这样,要查询2个时间之间的数据, 时间作为查询条件,可传可不传,可传1个,可传2个.
<if test="map.beginCreatetime != null and map.beginCreatetime != ''">
and DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%S') >= DATE_FORMAT(#{map.beginCreatetime}, '%Y-%m-%d %H:%i:%S')
</if>
<if test="map.endCreatetime != null and map.endCreatetime != ''">
and DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%S') <= DATE_FORMAT(#{map.endCreatetime}, '%Y-%m-%d %H:%i:%S')
</if>
时间戳转时间,再比较
<if test="beginCreatetime != null and beginCreatetime != ''">
and FROM_UNIXTIME(a.regtime) >= #{beginCreatetime}
</if>
<if test="endCreatetime != null and endCreatetime != ''">
and FROM_UNIXTIME(a.regtime) <= #{endCreatetime}
</if>
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!