date-week-func.sql 384 B

12345678910111213141516
  1. DELIMITER //
  2. CREATE FUNCTION DateWeek ( date VARCHAR(8) )
  3. RETURNS VARCHAR(8)
  4. BEGIN
  5. DECLARE month VARCHAR(5);
  6. DECLARE ret VARCHAR(8);
  7. declare w int;
  8. set w = week(date) ;
  9. set month = concat(substring(date, 3,2),'.',substring(date, 5,2)) ;
  10. set ret = concat(month,'-', if(length(w) = 1, concat('0',w), w) );
  11. RETURN ret;
  12. END; //
  13. DELIMITER ;
  14. drop function dateweek