Appointment Checking Code

Discussion in 'SQL Server' started by jtbrown1111, Aug 9, 2011.

  1. jtbrown1111

    jtbrown1111 New Member

    Joined:
    Aug 9, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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 ...
     
  2. alssadi

    alssadi Banned

    Joined:
    Dec 11, 2010
    Messages:
    41
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Creative director & web developer
    Location:
    Dubai
    Home Page:
    http://uaeinfographics.blogspot.com/
    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
     
  3. jtbrown1111

    jtbrown1111 New Member

    Joined:
    Aug 9, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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())))
     
  4. alssadi

    alssadi Banned

    Joined:
    Dec 11, 2010
    Messages:
    41
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Creative director & web developer
    Location:
    Dubai
    Home Page:
    http://uaeinfographics.blogspot.com/
    select * from app_date where day=1 AND month=10 or year=1990
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice