SELECT订单ID,case when '${type}'='天' then FORMAT(订单.订购日期,'hh')when '${type}'='月' then FORMAT(订单.订购日期,'DD')when '${type}'='年' then FORMAT(订单.订购日期,'MM')else FORMAT(订单.订购日期,'YYYY') END AS DATEFROM 订单 where 1=1 ${if(type=="天"," and date(订购日期)='"+ date +"'",if(type=="月"," and strftime('%m',订单.订购日期)='"+ month+"'"+" and strftime('%Y',订单.订购日期)='"+ year+"'"," and strftime('%Y',订单.订购日期)='"+ year+"'"))}一开始使用DATE_FORMAT 但是报错,换成了FOEMAT,但是好像不行,可以用MONTH或者YEAR截取出来吗,但是时间怎么截取,有点想不通了,因为是直接用在图表的,所以不能再单元格二次处理数据按照年月日替换的