根据日期参数,取当前日期前的所有历史数据,数据库里的年月是分开的
${if(Year<year(date),"","and Month<=month('"+date+"') ")}
我的语句是这样写的,但是会多出来一个Year参数,请问有没有更好的解决方法呢
你这个if判断能正确的取出参数日期之前的所有数据吗。
这个sql你试试看。
where ( (year=year(date) and month <=month(date)) or (year <year(date) ) )