i have searched these forums and found the following code to find the difference between two times. the prblem is when the time are in the save hour like a start time of 1:30 pm and a end time of 1:45 pm. instead of giving me 15 minutes it says the difference is 12:15 or of course 12 hours and 15 minutes.
this is what im using
Code:'test if there is a PM or AM in the box Text2 = Trim$(Text2) Dim intPMposition As Integer Dim intAMposition As Integer intPMposition = InStr(1, Text2, "PM") intAMposition = InStr(1, Text2, "AM") If intAMposition = 0 And intPMposition = 0 Then MsgBox "The time you entered needs to have either a AM or PM afer the time in the following format 1:30 PM.", vbCritical, "Time Format Error" Text2.SetFocus Exit Sub End If ' done testing Dim dblTime As Integer If CDate(Text1.Text) < CDate(Text2.Text) Then Dim datLap1 As Date, datLap2 As Date datLap1 = CDate(Text1.Text) datLap2 = CDate(Text2.Text) Dim datDifference As Date datDifference = datLap1 - datLap2 Text4 = Replace(Mid(datDifference, 1, InStrRev(datDifference, ":") - 1), ":", ".", 1, 1, vbTextCompare) Else Text4 = "" MsgBox "Your Time In is greater than your Time Out", vbInformation, "Time Error" End If


Reply With Quote
