我在MS Access程序中有一个表trans_hist,其中时间以短日期格式存储“HH:MM”ex:
[![图像] [1] [1]
现在我创建了一个查询,告诉每个用户的总时间(只是简单地总结时间),但如果总时间超过24小时,那么它会重置并从00:15重新开始(所有时间都存储在15分钟内)间隔)
问题:对于客户(UID)1,总时间应为32:30,但显示为8:30
当前结果:
UID Time_Elapsed
1 5:00
1 8:30
1 9:00
1 6:00
2 2:15
2 2:00
3 1:15
5 4:00
1 4:00
结果:
[![图像] [2] [2]
Cust_UID Trans_Date Agen_Name Prog_Name Prime_Serv Prime_Serv_Time 10014 13-Dec-15 LAC RA BMC 01:00 10021 14-Dec-15 LAC RA AP 01:00 10022 15-Dec-15 LAC RA AP 01:00 10021 16-Dec-15 LAC RA SM 00:45 10020 17-Dec-15 LAC RA AP 01:00 10027 18-Dec-15 LAC RA DA 00:15 10028 18-Dec-15 LAC RA DA 00:15 10026 18-Dec-15 LAC RA DA 00:15 10029 18-Dec-15 LAC RA DA 00:15 10030 18-Dec-15 LAC RA DA 00:15 10031 18-Dec-15 LAC RA DA 00:15 10023 19-Dec-15 LAC RA Clinical 02:00 10023 20-Dec-15 LAC RA Clinical 01:30 10023 20-Dec-15 LAC RA Clinical 02:00 10020 21-Dec-15 LAC RA SM 00:15 10023 21-Dec-15 LAC RA SM 00:30 10022 22-Dec-15 LAC RA Clinical 00:30 10022 22-Dec-15 LAC RA IB 00:30 10021 22-Dec-15 LAC RA IB 00:30 10009 22-Dec-15 LAC RA IB 00:30 10019 23-Dec-15 LAC RA STM 00:45 10009 23-Dec-15 LAC RA工作人员 - 00:30 10021 23-Dec-15 LAC RA工作人员 - 00:30 10022 23-Dec-15 LAC RA工作人员 - 00:30 10024 23-Dec-15 LAC RA员工 - 00:30 10033 23-Dec-15 LAC RA员工 - 00:30 10025 23-Dec-15 LAC RA Clinical 00:45 10035 28-Dec-15 LAC OA CA 05:00 10040 28-Dec-15 LAC OA CA 05:00 10039 28-Dec-15 LAC OA CA 05:00 10038 28-Dec-15 LAC OA CA 05:00 10042 28-Dec-15 LAC OA CA 05:00 10036 28-Dec-15 LAC OA CA 05:00 10037 28-Dec-15 LAC OA CA 05:00 10006 30-Dec-15 LAC Test 1 DA 01:45 10005 30-Dec-15 LAC Test 2 DG 01:45 10015 30-Dec-15 LAC Test 2 IB 02:15 10015 30-Dec-15 LAC Test 4 DG 03:15 10019 30-Dec-15 LAC OA CA 15:30 10005 31-Dec-15 LAC OA CA 12:00
[数据] [3]
结果
Prog_Name Prime_Serv Total_Serv_Time OA CA 62:30 RA AP 3:0 RA BMC 1:0 RA临床7:45 RA DA 2:30 RA IB 2:30 RA员工 - 2:30 RA SM 2:30 RA STM 1:45 测试1 DA 2:45 测试2 DG 2:45 测试2 IB 2:15 测试4 DG 3:15
[结果] [4]
答案 0 :(得分:2)
使用这样的函数:
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
和一个简单的查询:
Select
UID,
FormatHourMinute(Sum([Time_Elapsed])) As TotalTime
From
trans_hist
Group By
UID
答案 1 :(得分:0)
试试这个。
$('a.vegItem').on('click', function (event)
{
var VegSelection= $(this).text();
alert(VegSelection);
});
$('a.fruitItem').on('click', function (event)
{
var FruitSelection= $(this).text();
alert(FruitSelection);
});
答案 2 :(得分:0)
我希望,这个SQL查询有助于:
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