mysql中String类型日期比较

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/w592376568/article/details/81449149

    1、数据库中字段createtime类型为String,格式为:06-08-2018 10:50:24;

    2、以createtime做条件做时间范围内的查询操作:

   将String转为date:

<if test="start != null">
    and STR_TO_DATE(p.createtime,'%d-%m-%Y %H:%i:%s') &gt; STR_TO_DATE(#{start},'%d-%m-%Y %H:%i:%s')
</if>
<if test="end != null">
    and STR_TO_DATE(p.createtime,'%d-%m-%Y %H:%i:%s') &lt; STR_TO_DATE(#{end},'%d-%m-%Y %H:%i:%s')
</if>

​

猜你喜欢

转载自blog.csdn.net/w592376568/article/details/81449149