CREATE FUNCTION czas_trwania
(
    @rozp TIME(0),
	@zak TIME(0)
)
    RETURNS INT
AS
BEGIN
    RETURN DATEDIFF(mi, @rozp, @zak)
END;
GO