• Status: Solved
  • Priority: Medium
  • Security: Private
  • Views: 44
  • Last Modified:

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?
0
deer777
Asked:
deer777
1 Solution
 
PatHartmanCommented:
You would use the Datediff() function to give you the difference in minutes.  Then divide by 60 to give you hours and the remainder will be minutes.

I've attached a database full of date functions that wiil help.
UsefulDateFunctions180110.zip
0
 
Gustav BrockCIOCommented:
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

0
 
deer777Author Commented:
Thanks so much for all the extra information!!!

Greatly appreciated!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now