sumar horas en access

17/10/2003 - 17:11 por FORMACION | Informe spam
Por favor necesito sumar horas en access.
Pej: 20:00:25 +21:52:00 + 15:12:00
 

Leer las respuestas

#1 CarCar
17/10/2003 - 18:16 | Informe spam
Hola:

Pues supongo que tendrás que crearte un procedimiento que
lo haga, porque las herramientas que trae Access (a lo
mejor me equivovo) suman fechas y por lo tanto si intentas
sumar las horas que pones te dará el día 2 de enero de
1899...

La siguiente función, por ejemplo, suma 2 horas válidas
que tengan formato fecha:

Function SumaHoras(H1 As Date, H2 As Date) As String
Dim Seg As Integer
Dim Min As Integer
Dim Hor As Integer

Seg = Second(H1) + Second(H2)
Min = Minute(H1) + Minute(H2)
Hor = Hour(H1) + Hour(H2)

If Seg >= 60 Then
Seg = Seg - 60
Min = Min + 1
End If

If Min >= 60 Then
Min = Min - 60
Hor = Hor + 1
End If

SumaHoras = Hor & ":" & Min & ":" & Seg
End Function

Si ejecutas por ejemplo:

?sumahoras("12:55:55","22:56:54")

devuelve en un campo de tipo String (texto) : 35:52:49

Saludos,
CarCar
MVP-Access


Por favor necesito sumar horas en access.
Pej: 20:00:25 +21:52:00 + 15:12:00


.

Preguntas similares