第一种数据类型是字符串类型
<if test="startTime!=null and startTime.trim() neq ''">
and date_format(create_time,'%Y-%m-%d %H:%i:%s')
>= str_to_date(#{startTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test="endTime!=null and endTime.trim() neq ''">
and date_format(create_time,'%Y-%m-%d %H:%i:%s')
<= str_to_date(#{endTime},'%Y-%m-%d %H:%i:%s')
</if>
这是我的写法,可以查询出来当天时间的区间
<if test="createTime != null">
AND crp.create_time between DATE_FORMAT(##{createTime},'%Y-%m-%d 00:00:00')
and DATE_FORMAT(#{endTime},'%Y-%m-%d 23:59:59')
</if>
第二种数据类型是DATA类型
<if test="startTime!=null and startTime.trim() neq ''">
and date_format(create_time,'%Y-%m-%d %H:%i:%s')
>= date_format(#{startTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test="endTime!=null and endTime.trim() neq ''">
and date_format(create_time,'%Y-%m-%d %H:%i:%s')
<= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
</if>