What is the Best Practice of designing a table for storing a period of dates, Query for fiding the period

  • Hi Friends,

    I have to add a table to our existing database which will be storing the a period of time i.e Say Summer Vacation it will be for 3 weeks and people will be providing me the start date. I have to calculate automatically the next 3 weeks using find week query"SELECT DATEPART( wk, '2010-04-15 23:12:04.000')". How can i change this query or write a new query to take current date and provide me the ouput as yes when current date falls in that Summer vacation.

  • Ismail Ahmed (3/8/2010)


    Hi Friends,

    I have to add a table to our existing database which will be storing the a period of time i.e Say Summer Vacation it will be for 3 weeks and people will be providing me the start date. I have to calculate automatically the next 3 weeks using find week query"SELECT DATEPART( wk, '2010-04-15 23:12:04.000')". How can i change this query or write a new query to take current date and provide me the ouput as yes when current date falls in that Summer vacation.

    Use DATEADD to calculate the other boundary and use it in a CASE statement. If you want a more specific coded answer, please provide more specific data to test with. See the first link in my signature line below for how to do that.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply