首页 > 其他分享 >报错:FUNCTION .to_char does not exist(to_char与date_format)

报错:FUNCTION .to_char does not exist(to_char与date_format)

时间:2022-08-17 11:00:54浏览次数:73  
标签:FUNCTION -% format char 报错 time date order

错误代码:

<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
From: https://www.cnblogs.com/zwh0910/p/16594299.html

相关文章