-
mysql查询时间段数据
1. //查询从当天倒回30的数据,如果查询数据库两个时间可以直接引用
2. $starttime=date("Y-m-d", strtotime("-30 days", time()));//-30;从现在时间倒回30
3. $endtime=date("Y-m-d");
4. select * from services where DATE_FORMAT(laifangtime, '%Y-%m-%d') >= '$starttime' and DATE_FORMAT(laifangtime, '%Y-%m-%d') <= '$endtime'
2.mybatis查询时间段数据
<if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
<![CDATA[ and DATE_FORMAT(mm.create_time, '%Y-%m-%d')>= DATE_FORMAT(#{startDate}, '%Y-%m-%d') ]]>
<![CDATA[ and DATE_FORMAT(mm.create_time, '%Y-%m-%d') < DATE_FORMAT(#{endDate}, '%Y-%m-%d') ]]>
</if>