DELIMITER $$DROP FUNCTION IF EXISTS `test`.`dateformat1`$$ CREATE FUNCTION dateformat1 ( monthyear nvarchar(80), day nvarchar(80), n Int) RETURNS nvarchar(80)BEGIN Declare s1 varchar(80); Declare s2 varchar(80); declare i int; set i=1; set s1 = ''; loop1: loop SET s1 = s1 + substring(monthyear,i,1); IF i = n then LEAVE loop1; ELSE set i = i+1; ITERATE loop1; END IF; END loop loop1; SET s1 = s1 + day + substring(monthyear,i,length(monthyear)-i+1 ); RETURN s1; END$$DELIMITER ; select dateformat1 ('09/2009','01/',4);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)