_prev_date.sql 353 B

12345678910111213141516
  1. DELIMITER //
  2. create function _prev_date ( _date varchar(8) )
  3. returns VARCHAR(8)
  4. begin
  5. declare ret varchar(8);
  6. declare pmDate datetime;
  7. set pmDate = date_add( _date, interval -1 day);
  8. set ret = concat(substring(pmDate, 1,4),substring(pmDate, 6,2),substring(pmDate, 9,2));
  9. RETURN ret;
  10. end; //
  11. DELIMITER ;
  12. select _prev_date('20220102')