Delimiter //
/**
function CASH_ISVALIDDATEFORMAT
	Check if format is acepted date format

	return <=0 if not accepted date format
	return = 1 if accepted date format with no delimiter (iso) : UMD
	return = 2 if accepted date format with delimiter. French or italian format : D/M/Y
	return = 3 if accepted date format with delimiter. UK format : M/D/Y
	return = 4 if accepted date format with delimiter. US format Y/M/D
**/
drop function if exists CASH_ISVALIDDATEFORMAT//

create function CASH_ISVALIDDATEFORMAT (format varchar(20))
	returns int
Begin
	If format regexp '^([yY]{2}){1,2}[mM]{1,2}[dD]{1,2}$' Then
		-- ISO
		-- empty string delimiter
		return 1;
	Elseif format regexp '^[dD]{1,2}[-/][mM]{1,2}[-/]([yY]{2}){1,2}$' Then
		-- french or italien
		return 2;
	ElseIf format regexp '^[mM]{1,2}[-/][dD]{1,2}[-/]([yY]{2}){1,2}$' Then
		-- UK
		return 3;
	ElseIf format regexp '^([yY]{2}){1,2}[-/][mM]{1,2}[-/][dD]{1,2}$' Then
		-- US
		return 4;
	Else
		return 0;
	End If;
End //

Delimiter ;

