DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticket_getCurrencyDate`(vSelf INT)
	RETURNS INT(11)
	DETERMINISTIC
BEGIN
	DECLARE vCurrencyDated DATE;

	SELECT IF(DATE(shipped) < util.VN_CURDATE(), shipped, util.yesterday())  INTO vCurrencyDated
		FROM ticket
			WHERE id = vSelf;

	RETURN vCurrencyDated;
END$$
DELIMITER ;

