date-week-func.sql 405 B

1234567891011121314151617
  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. declare w int;
  9. set w = week(date) ;
  10. set month = concat(substring(date, 3,2),'.',substring(date, 5,2)) ;
  11. set ret = concat(month,'-', if(length(w) = 1, concat('0',w), w) );
  12. RETURN ret;
  13. END; //
  14. DELIMITER ;
  15. drop function dateweek