日期出来了SQL就简单了瑟
if(and(year(today())=$年,MONTH(today())*1==$月),CONCATENATE("同期:",DATEINMONTH(MONTHDELTA(today(),-1),1),"至",MONTHDELTA(today(),-1)),
CONCATENATE("同期:",DATEINMONTH(MONTHDELTA(DATE($年,$月,1),-1),1),"至",DATEINMONTH(MONTHDELTA(DATE($年,$月,1),-1),-1))
)