Calling a function within stored procedure to derive a value
Calling a function from a stored procedure is absolutely fine.

As far as the code goes, you could reduce the number of statements.

e.g. instead of

 IF @timeDifferenceInHours &gt;= 0 AND @timeDifferenceInHours &lt;= 24
     BEGIN 
        SELECT @timeDifference = @timeDifferenceInHours
     END
  ELSE
    BEGIN
        SELECT @timeDifference = -1
    END


I would suggest

  select @timedifference = 
    case when @timeDifferenceInHours &gt;= 0 AND @timeDifferenceInHours &lt;= 24
         then @timeDifferenceInHours
         else -1 
    end