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 ...
|
Banned
|
|
| 10Aug2011,04:10 | #2 |
|
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 |
|
Newbie Member
|
|
| 10Aug2011,06:14 | #3 |
|
This is what I've tried and it works, does anyone know a better way to do this ....
(MONTH(APPT.Appointment_DateTime)=MONTH(DATEADD(DAY, 3,GETDATE())))AND (DAY(APPT.Appointment_DateTime)=DAY(DATEADD(DAY, 3,GETDATE())))AND (YEAR(APPT.Appointment_DateTime)=YEAR(DATEADD(DAY, 3,GETDATE())))OR (MONTH(APPT.DateTime_Scheduled)=MONTH(DATEADD(DAY, 0,GETDATE())))AND (DAY(APPT.DateTime_Scheduled)=DAY(DATEADD(DAY, 0,GETDATE())))AND (YEAR(APPT.DateTime_Scheduled)=YEAR(DATEADD(DAY, 0,GETDATE())))AND (MONTH(APPT.Appointment_DateTime)=MONTH(DATEADD(DAY, 1,GETDATE())))AND (DAY(APPT.Appointment_DateTime)=DAY(DATEADD(DAY, 1,GETDATE())))AND (YEAR(APPT.Appointment_DateTime)=YEAR(DATEADD(DAY, 1,GETDATE())))OR (MONTH(APPT.DateTime_Scheduled)=MONTH(DATEADD(DAY,- 1,GETDATE())))AND (DAY(APPT.DateTime_Scheduled)=DAY(DATEADD(DAY,- 1,GETDATE())))AND (YEAR(APPT.DateTime_Scheduled)=YEAR(DATEADD(DAY,- 1,GETDATE())))AND (MONTH(APPT.Appointment_DateTime)=MONTH(DATEADD(DAY, 2,GETDATE())))AND (DAY(APPT.Appointment_DateTime)=DAY(DATEADD(DAY, 2,GETDATE())))AND (YEAR(APPT.Appointment_DateTime)=YEAR(DATEADD(DAY, 2,GETDATE()))) |
|
Banned
|
|
| 11Aug2011,23:02 | #4 |
|
select * from app_date where day=1 AND month=10 or year=1990
|
