I have a table trans_hist in MS Access program where time is stored in short Date format \"HH:MM\" ex:
[![Image][1]][1]
Now I have created a query which tell
Try this.
SELECT UID, switch (
t>1 , '00:15'
,true,format(t,'hh:mm')
) as Time_Elapsed from
(
SELECT UID, sum(Time_Elapsed) as t
From Table1
Group By UID
)
Use a function like this:
Public Function FormatHourMinute( _
ByVal datTime As Date, _
Optional ByVal strSeparator As String = ":") _
As String
' Returns count of days, hours and minutes of datTime
' converted to hours and minutes as a formatted string
' with an optional choice of time separator.
'
' Example:
' datTime: #10:03# + #20:01#
' returns: 30:04
'
' 2005-02-05. Cactus Data ApS, CPH.
Dim strHour As String
Dim strMinute As String
Dim strHourMinute As String
strHour = CStr(Fix(datTime) * 24 + Hour(datTime))
' Add leading zero to minute count when needed.
strMinute = Right("0" & CStr(Minute(datTime)), 2)
strHourMinute = strHour & strSeparator & strMinute
FormatHourMinute = strHourMinute
End Function
and a simple query:
Select
UID,
FormatHourMinute(Sum([Time_Elapsed])) As TotalTime
From
trans_hist
Group By
UID
I hope, this SQL query helps:
SELECT T.UID,
CSTR(total_hours
+ INT(total_min / 60))
+ ":"
+ CSTR(total_min Mod 60) as result
FROM
(SELECT UID,
SUM(HOUR(TH.time_elapsed)) AS total_hours,
SUM(MINUTE(TH.time_elapsed)) AS total_min
FROM trans_hist AS TH
GROUP BY UID) AS T