time query

G

Guest

I need to caculate the difference between appointment time(located in Table)
and current time
 
G

Guest

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
 
J

jahoobob via AccessMonster.com

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)
 
J

Jeff Boyce

The reponses you've received will work if your [AppointmentTime] field is a
Date/Time data type.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

time query 2
How can I retrieve GMTwithout calculating it in Access 2003? 1
#Error 2
Datedif function 1
Adding times in Access 1
Need formula 4
How do I caculate 24 hour military times 6
Creating a Project 1

Top