CREATE FUNCTION `Format_Date`( in_date VARCHAR ( 50 )) RETURNS varchar(50) CHARSET latin1 NOT DETERMINISTIC SQL SECURITY DEFINER COMMENT '' begin declare temp_str CHAR(50); declare m_str CHAR(50); declare d_str CHAR(50); declare y_str CHAR(50); declare pos int; set temp_str = in_date; set pos = if(position('/' in temp_str)=0,length(temp_str),position('/' in temp_str) -1); set m_str = mid(in_date,1,pos); set temp_str = substring(in_date,position('/' in in_date)+1,length(in_date)-position('/' in in_date)); set pos = if(position('/' in temp_str)=0,length(temp_str),position('/' in temp_str) -1); set d_str =mid(temp_str,1,pos); set temp_str = substring(temp_str,position('/' in temp_str)+1,length(temp_str)-position('/' in temp_str)); set pos = if(position('/' in temp_str)=0,length(temp_str),position('/' in temp_str) -1); set y_str =mid(temp_str,1,pos); return concat(y_str,'-',m_str,'-',d_str); end;
mysql 创建函数(function)
最新推荐文章于 2023-10-25 15:45:56 发布