22/10/2009, 15:10
|
| Colaborador | | Fecha de Ingreso: julio-2007 Ubicación: Mexico, D.F.
Mensajes: 6.482
Antigüedad: 17 años, 5 meses Puntos: 180 | |
Respuesta: Convertir valor a date Bueno, eso de HR y MIN es un simple texto, aqui lo interesante del asunto, es SUMAR las horas, minutos y segundos, para "CONVERTIR" de los totales, las correspondientes HORAS, MINUTOS Y SEGUNDOS.
/*
create table #TEST(Duracion DATETIME)
INSERT INTO #TEST VALUES('1900-01-01 00:00:32.000')
INSERT INTO #TEST VALUES('1900-01-01 00:01:28.000')
INSERT INTO #TEST VALUES('1900-01-01 00:01:02.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:08.000')
INSERT INTO #TEST VALUES('1900-01-01 00:02:13.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:27.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:18.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:17.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:16.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:11.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:39.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:13.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:10.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:19.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:26.000')
INSERT INTO #TEST VALUES('1900-01-01 00:01:46.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:58.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:55.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:32.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:48.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:48.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:58.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:32.000')
INSERT INTO #TEST VALUES('1900-01-01 00:02:14.000')
INSERT INTO #TEST VALUES('1900-01-01 00:01:11.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:21.000')
INSERT INTO #TEST VALUES('1900-01-01 00:00:35.000')
SELECT
X.HORAS + (X.MINUTOS/60) + ((X.SEGUNDOS / 60) / 60) AS HORAS,
(X.SEGUNDOS / 60 + X.MINUTOS) % 60 AS MINUTOS,
X.SEGUNDOS % 60 AS SEGUNDOS
FROM ( SELECT
SUM(DATEPART(HH, DURACION)) AS HORAS,
SUM(DATEPART(MI, DURACION)) AS MINUTOS,
SUM(DATEPART(SS, DURACION)) AS SEGUNDOS
from #TEST)
AS X
*/ |