Link to home
Start Free TrialLog in
Avatar of deer777
deer777Flag for United States of America

asked on

Access Form Calculate on 2 textboxes the hours of the day difference: 8:00 am 10:07 am need to know difference in hours minutes

Calculate on form 2 textboxes the hours of the day difference:  8:00 am   10:07 am  

Need to know difference in hours minutes

How would I calculate this?
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can use my function below. Then:

StartTime = #8:00 AM#
StopTime = #10:07 AM#
Difference = FormatHourMinute(StopTime - StartTime)
? Difference
2:07

Open in new window


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

Open in new window

Avatar of deer777

ASKER

Thanks so much for all the extra information!!!

Greatly appreciated!