Sorry, Dinesh, you've got so many titles... Just like number of operands in your script.
But what about performance of your scripts? It's good while it has only 4 rows to work out.
What if you replace your function with this one?
CREATE FUNCTION dbo.fn_getDuration (@STime datetime, @ETime datetime)
RETURNS datetime
AS
BEGIN
DECLARE @Duration Datetime
SET @Duration = @ETime-@STime
RETURN @Duration - floor(convert(real, @Duration))
END
First, it's more precise: it counts not only hours and minutes, but seconds and milliseconds as well. So, it's more usefull;
Second, it works times faster;
And third, it returns datetime value, so you can use it in criteria check for select from big table: WHERE dbo.fn_getDuration (..) > '05:00:00'
Best regards,
Sergiy.
_____________
Code for TallyGenerator