我正在使用此功能
Public Function ElapsedTime(Start As Date, Finish As Date) As String
'Calculates elapsed time between 2 date/times and
'parses it out into Hours-Minutes-Seconds in HH:MM:SS format
Dim HoursLapsed, SecondsLeft, MinutesLapsed, SecondsLapsed, TotalSeconds As Long
TotalSeconds = DateDiff("s", Start, Finish)
HoursLapsed = Int(TotalSeconds / 3600)
SecondsLeft = TotalSeconds Mod 3600
MinutesLapsed = Int(SecondsLeft / 60)
SecondsLapsed = SecondsLeft Mod 60
ElapsedTime = Format(HoursLapsed, "00") & ":" & Format(MinutesLapsed, "00") & ":" & Format(SecondsLapsed, "00")
End Function
这是我的查询
SELECT
ElapsedTime([Date_Faxed],[Date_Found]) AS Duration,
dbo_yard_request.Salesman,
dbo_yard_request.Make,
dbo_yard_request.Model,
dbo_yard_request.ID,
dbo_yard_request.Found2
FROM
dbo_yard_request
WHERE
(((dbo_yard_request.Found2)=True));
它工作正常,但我需要考虑到当天下午5点和新的一天早上8点开始。
例如
DATE_FAXED = 1/22/2015 4:45:22 PM
DATE_FOUND = 1/23/2015 8:55:13 AM
经过的时间应为1小时10分钟,而不是16小时