报错:FUNCTION .to_char does not exist(to_char与date_format)
作者:互联网
错误代码:
<if test="startDate!=null and startDate!=''">
AND to_char(o.order_time, 'yyyy-mm-dd') <![CDATA[>=]]> #{startDate}
</if>
<if test="endDate!=null and endDate!=''">
AND to_char(o.order_time, 'yyyy-mm-dd') <![CDATA[<=]]> #{endDate}
</if>
原因分析:mysql中没有to_char函数,应该使用date_format,日期转为字符串使用 date_format(create_time,’%Y-%m-%d %H:%i:%s’)
修改如下:
<if test="startDate!=null and startDate!=''"> AND date_format(o.order_time, '%Y-%m-%d') <![CDATA[>=]]> #{startDate} </if> <if test="endDate!=null and endDate!=''"> AND date_format(o.order_time, '%Y-%m-%d') <![CDATA[<=]]> #{endDate} </if>
标签:FUNCTION,-%,format,char,报错,time,date,order 来源: https://www.cnblogs.com/zwh0910/p/16594299.html