Go4Expert (http://www.go4expert.com/)
-   SQL Server (http://www.go4expert.com/forums/sql-server-forum/)
-   -   Appointment Checking Code (http://www.go4expert.com/forums/appointment-checking-code-t26466/)

jtbrown1111 10Aug2011 01:13

Appointment Checking Code
I'm needing help with coding a sql search. We are a medical faciltity and need to create a list of upcoming appointments. We look 3 days in the future on appointments, so I've created a query that simply looks at appointments that are today +3. But what I"m missing are the appointments we'll make tommorrow and the next day for my original appointment date.

I beleive I need to check items with an appt_date = (today+3) and also check appointments which were scheduled the privious two days for tomorrow and the next day so I don't miss any .....

HOpe this makes sense ....

What is the best way to code this so each day I check for this ..... I'm not a sql programmer by trade .....

Thanks so much for your help ...

alssadi 10Aug2011 04:10

Re: Appointment Checking Code
select * from app_date where date=(the date)

simple select the date that you want to check any date , if you created on that table a date filed .

hope that help

jtbrown1111 10Aug2011 06:14

Re: Appointment Checking Code
This is what I've tried and it works, does anyone know a better way to do this ....

(DAY(APPT.Appointment_DateTime)=DAY(DATEADD(DAY, 3,GETDATE())))AND


(DAY(APPT.Appointment_DateTime)=DAY(DATEADD(DAY, 1,GETDATE())))AND

(DAY(APPT.Appointment_DateTime)=DAY(DATEADD(DAY, 2,GETDATE())))AND
(YEAR(APPT.Appointment_DateTime)=YEAR(DATEADD(DAY, 2,GETDATE())))

alssadi 11Aug2011 23:02

Re: Appointment Checking Code
select * from app_date where day=1 AND month=10 or year=1990

All times are GMT +5.5. The time now is 09:09.