CREATE FUNCTION change_time_to_minutes(@date TIME) RETURNS INT
AS
BEGIN
	DECLARE @HOURS INT;
	DECLARE @MINUTES INT;

	SET @HOURS = CONVERT(INT, FORMAT(@date, 'hh'));
	SET @MINUTES = CONVERT(INT, FORMAT(@date, 'mm'));

	RETURN @HOURS * 60 + @MINUTES;
END;
