Delimiter //
/**
function CASH_TODATE
	convert varchar to date
**/

drop function if exists CASH_TODATE //

create function CASH_TODATE(value varchar(255), format Int, delimiter Varchar(1) )
	returns Date
Begin
	Declare
			validFormat, century,
			dVal, mVal, yVal
		int;

	call CASH_DATEPART(value, format, delimiter, dval, mval, yVal, validFormat);
	if validFormat<1 Then
		return null;
	End if;
	return Cast(Concat(yVal, '/', mval, '/', dval) AS date);

End //
Delimiter ;