Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determing the number of minutes or hours that elapsed between times 1

Status
Not open for further replies.

vaughn9

Technical User
Sep 23, 2001
183
Ihave placed a digital clock on a form using a timer and a label control. the interval on the timer is set to 1000 and the code in the timer says lbltime=time.

I need to register the clock out time and clock in time(for a worker who takes a break) and figure out minutes or hours that elapsed between the 2 times.

I placed a button captioned clockout which has the code (text1=timer1) so that the clock out time could go into a text box. I did the same for another textbox for the clockin time.

I then tried to find the elapsed time between the two times
by writing code in a command button that would subtract the two times in the text box but I get the error mismatch. when I change the textboxes to value I get 0

Does anyone know how I can subtract the two times to get the elapsed time in minutes or hours?

 
Have a look at the [blue]DateDiff[/blue] function.

here's an example to get you started

Code:
Dim time1 As String
Dim time2 As String

time1 = "10:00:00"
time2 = "10:02:00"

MsgBox "Time diff = " & DateDiff("n", CDate(time1), CDate(time2)) & " minutes"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top