select part_dt, store_id, business_volume , valid_order, unit_price from ads_mkt_platform_store_day where 1=1 ${IF(frequency="1","AND part_dt >= '"+startDate+"' AND part_dt< '"+endDate+"'" , IF(frequency="2","AND part_dt >= '"+startDate+"' AND part_dt< '"+endDate+"'", IF(frequency="3","AND part_dt >= '"+startDate+"' AND part_dt< '"+endDate+"'" ,"AND part_dt >= '"+startDate+"' AND part_dt< '"+endDate+"'")))} and store_id in ( '${store_id}') 数据库是mysql,part_dt是日分区,存放的格式20010203的字符串,startDate,endDate是传参,想通过date_format()函数转换日期格式报错,哪位大佬指教一下,怎么转日期格式,还有就是取到昨天,去年同一天的日期?,if 条件中frequency 表示取 日 周 三个时间维度,查看数据 select part_dt, store_id, business_volume , valid_order, unit_price from ads_mkt_platform_store_day where 1=1 ${IF(frequency="1","AND part_dt >= '"+date_format(startDate,'%Y%m%d')+"' AND part_dt< '"+date_format(endDate,'%Y%m%d')+"'" , IF(frequency="2","AND part_dt >= '"+date_format(startDate,'%Y%m%d')+"' AND part_dt< '"+date_format(endDate,'%Y%m%d')+"'", IF(frequency="3","AND part_dt >= '"+date_format(startDate,'%Y%m%d')+"' AND part_dt< '"+date_format(endDate,'%Y%m%d')+"'" ,"AND part_dt >= '"+date_format(startDate,'%Y%m%d')+"' AND part_dt< '"+date_format(endDate,'%Y%m%d')+"'")))} and store_id in ( '${store_id}') |