Appointment Rebooking

I need some assistance with some SQL

I have a table that contains appointments

AppName       AppDate         AppTime

After an appointment has been booked, a ' Rebook' button is available for people to rebook that appointment if the time and date changes..

This all works but what I want to do now is this.

When people try to rebook I DON"T want them to be able to choose a date that is AFTER the next appointment.

e.g

Appointment 1    01/05/2015

Appointment 2     15/05/2015

If people choose to rebook appointment 1 then I want it to stop people choosing a date beyond Appointment 2.  So the only available dates to rebook would be between 01/05/2015  and 15/05/2015.

Thanks
EdAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Easwaran ParamasivamCommented:
Simple. Add validation by calling an SP while re-booking. Pass the selected date as input parameter to the SP


create proc Validate (@Input datetime)
as
begin
 
declare @retvalue int =  0


--Assuming tTable contains the Appointment2  data value. Kindly change in your case accordingly.
if exists (select   1
from tTable where   Appointment2 < @Input )
set @retvalue =  0
else
set @retvalue =  1

--In UI read the @retvalue. If it is 1 then it fails the validation. In this case don't allow to rebook

 

end
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EdAuthor Commented:
thanks, could you give a bit of SQL to assist with this?
0
Easwaran ParamasivamCommented:
0
EdAuthor Commented:
Perfect , thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.