date-week-func-old1.sql 357 B

123456789101112
  1. DELIMITER //
  2. CREATE FUNCTION DateWeek ( date VARCHAR(8) )
  3. RETURNS VARCHAR(8)
  4. SQL SECURITY INVOKER
  5. BEGIN
  6. DECLARE month VARCHAR(5);
  7. DECLARE ret VARCHAR(8);
  8. set month = concat(substring(date, 3,2),'.',substring(date, 5,2)) ;
  9. set ret = concat(month,'-',week(date)- week(concat(substring(date, 1,6),'01'))+1);
  10. RETURN ret;
  11. END; //
  12. DELIMITER ;