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!

DateDiff

Status
Not open for further replies.

Taff82

Programmer
Feb 11, 2004
43
GB
Hi all,

Bit stuck with this one.

I have a table called appointments with the following fields
AppDate, AppTime, AppComments and these are also on my form called frmAppointments.

What I am trying to do is check how much time there is between the appointment that is currently open on my form and the next due appointment for that day. If there is no next due appointment then I'm trying to work out the difference in time between my currently selected appointment and the time 17:30:00.

Have tried the DateDiff function and have gotten it to work, however when there are no more scheduled appointments for that day I get completely lost.

Any help is greatly appreciated.

Thanks

Taff.
 
Have tried the DateDiff function and have gotten it to work
Can you please post the relevant code ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks both for replying.

The statement in my query is:

Code:
SELECT tblAppointments.AppDate, tblAppointments.AppTime, DateDiff("n",[Forms]![FrmAppointments]![AppTime],[AppTime]) AS TimeDifference
FROM tblAppointments
WHERE (((tblAppointments.AppDate)=[Forms]![FrmAppointments]![AppDate]) AND ((tblAppointments.AppTime)>[Forms]![FrmAppointments]![AppTime]));

However if no results are returned for my query this is where I get stuck.

Taff.
 
And how is this query used in your checking process ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
It will be used to tell me what the maximum length of the appointment can be.

Taff.
 
Some thing like this in the AfterUpdate event procedure of the AppTime control ?
stCrit = "AppDate=#" & Format(Me!AppDate, "yyyy-mm-dd") & "# AND AppTime>#" & Format(Me!AppTime, "hh:nn:ss") & "#"
myTimediff = DateDiff("n", Me!AppTime, Nz(DLookUp("AppTime", "tblAppointments", stCrit), #17:30:00#))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top