time query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to caculate the difference between appointment time(located in Table)
and current time
 
Hi,
you can use the DateDiff function for this in a query e.g.:
Difference: DateDiff("n",[YourField],Now())

This would return the difference in minutes.
HTH
Good luck
 
If you want it in the form hh:mm, place this in your query:
Tm: Tim(DateDiff("n",[Begin Time],[End Time])/60)
and create a function:

Function Tim(DecTime As Single) As String
Dim hours, minutes As Integer
Dim Min$

hours = Str(Int(Val(DecTime)))
minutes = Str((Val(DecTime) - hours) * 60)

If minutes > 0 Then
If minutes > 10 Then
Min$ = ":" + Right(Str(Int(minutes)), 2)
Else
Min$ = ":0" + Right(Str(Int(minutes)), 1)
End If
Else
Min$ = ":00"
End If

Tim = hours + Min$
End Function

If you just want minutes place this in the query:
Tm: (DateDiff("n",[Begin Time],[End Time])/60)
 
The reponses you've received will work if your [AppointmentTime] field is a
Date/Time data type.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Back
Top