Prueba esta opción:
Código SQL:
Ver originalALTER FUNCTION dbo.Funcionhrsminsec
(
@FromDate DATETIME,
@ToDate DATETIME
)
RETURNS VARCHAR(80)
AS
BEGIN
RETURN (SELECT CAST(Horas AS VARCHAR)+CASE WHEN Horas=1 THEN ' Hora, ' ELSE ' Horas, ' END+
CAST(Minutos AS VARCHAR)+CASE WHEN Minutos=1 THEN ' Minuto, ' ELSE ' Minutos, ' END+
CAST(Segundos AS VARCHAR)+CASE WHEN Segundos=1 THEN ' Segundo' ELSE ' Segundos' END
FROM (SELECT Scnd/3600 Horas,
(Scnd%3600)/60 Minutos,
(Scnd%3600)%60 Segundos
FROM (SELECT DateDiff(SECOND,FromDate,ToDate) Scnd
FROM (SELECT CASE WHEN @FromDate>@ToDate THEN @ToDate ELSE @FromDate END FromDate,
CASE WHEN @FromDate>@ToDate THEN @FromDate ELSE @ToDate END ToDate) T1) T2) T3);
END