DELIMITER //

create function _prev_date ( _date varchar(8) )
returns VARCHAR(8)

begin
   declare ret varchar(8);
   declare pmDate datetime;
	   set pmDate = date_add( _date, interval -1 day);
	   set ret = concat(substring(pmDate, 1,4),substring(pmDate, 6,2),substring(pmDate, 9,2));
   RETURN ret;
end; //

DELIMITER ;

select _prev_date('20220102')