我正在跟踪每周工作时间,并且无法格式化持续时间以显示38:28
而不是14:28
。在excel中它将是[h]:mm
,但我无法在MS Access中重新创建它。有什么想法吗?
答案 0 :(得分:0)
您可以使用此功能:
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
然后在您的查询中使用此表达式:
Duration: FormatHourMinute([Stop]-[Start])